Example #1
0
def bounding_circles(in_fc, out_fc, kind=2):
    """Minimum area bounding circles.  Change `angle=5` to a smaller value for
    denser points on circle perimeter.
    """
    result = check_path(out_fc)
    if result[0] is None:
        print(result[1])
        return result[1]
    gdb, name = result
    SR = getSR(in_fc)  # getSR, shape_to_K  and fc_geometry from
    kind = shape_to_K(in_fc)  # npGeo_io
    tmp, IFT, IFT_2 = fc_geometry(in_fc, SR)
    m = np.nanmin(tmp, axis=0)  # shift to bottom left of extent
    info = "bounding circles"
    a = tmp - m
    g = Geo(a, IFT=IFT, Kind=kind, Info=info)  # create the geo array
    out = g.bounding_circles(angle=2, return_xyr=False)
    circs = [arr + m for arr in out]
    circs = Update_Geo(circs, K=2, id_too=None, Info=info)
    # ---- produce the geometry
    p = "POLYGON"
    if kind == 1:
        p = "POLYLINE"
    geometry_fc(circs, circs.IFT, p_type=p, gdb=gdb, fname=name, sr=SR)
    return "{} completed".format(out_fc)
Example #2
0
def circles(in_fc, gdb, name, kind):
    """Minimum area bounding circles.  Change `angle=2` to a smaller value for
    denser points on circle perimeter.
    `getSR`, `shape_k`  and `fc_geometry` are from npg_io.
    """
    SR = getSR(in_fc)
    kind, k = shape_K(in_fc)
    tmp, IFT = fc_geometry(in_fc, SR=SR, IFT_rec=False)
    m = np.nanmin(tmp, axis=0)                   # shift to LB of whole extent
    info = "bounding circles"
    a = tmp - m
    g = Geo(a, IFT, k, info)                     # create the geo array
    out = g.bounding_circles(angle=2, return_xyr=False)
    circs = [arr + m for arr in out]
    k = 1
    if kind == 'Polygons':
        k = 2
    circs = Update_Geo(circs, K=k, id_too=None, Info=info)
    # produce the geometry
    p = kind.upper()
    geometry_fc(circs, circs.IFT, p_type=p, gdb=gdb, fname=name, sr=SR)
    return "{} completed".format("Circles")