Ejemplo n.º 1
0
def extent_poly(in_fc, gdb, name, kind):
    """Feature envelope to polygon demo.

    Parameters
    ----------
    in_fc : string
        Full geodatabase path and featureclass filename.
    kind : integer
        2 for polygons, 1 for polylines

    References
    ----------
    `Feature Envelope to Polygon
    <https://pro.arcgis.com/en/pro-app/tool-reference/data-management/feature
    -envelope-to-polygon.htm>`_.

    >>> data = fc_data(in_fc)
    """
    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 extent
    info = "extent to polygons"
    a = tmp - m
    g = Geo(a, IFT, k, Info=info)   # create the geo array
    ext = g.extent_rectangles()   # create the extent array
    ext = ext + m                 # shift back, construct the output features
    ext = Update_Geo(ext, K=k, id_too=None, Info=info)
    # ---- produce the geometry
    p = kind.upper()
    geometry_fc(ext, ext.IFT, p_type=p, gdb=gdb, fname=name, sr=SR)
    return "{} completed".format("Extents")
Ejemplo n.º 2
0
def extent_poly(in_fc, out_fc, kind):
    """Feature envelop to polygon demo.

    Parameters
    ----------
    in_fc : string
        Full geodatabase path and featureclass filename.
    kind : integer
        2 for polygons, 1 for polylines

    References
    ----------
    `Feature Envelope to Polygon
    <https://pro.arcgis.com/en/pro-app/tool-reference/data-management/feature
    -envelope-to-polygon.htm>`_.

    >>> data = fc_data(in_fc)
    """
    result = check_path(out_fc)
    if result[0] is None:
        tweet(result[1])
        return result[1]
    gdb, name = result
    # ---- done checks
    SR = getSR(in_fc)
    tmp, IFT, IFT_2 = fc_geometry(in_fc, SR)
    SR = getSR(in_fc)
    m = np.nanmin(tmp, axis=0)  # shift to bottom left of extent
    info = "extent to polygons"
    a = tmp - m
    g = Geo(a, IFT=IFT, Kind=kind, Info=info)  # create the geo array
    ext = g.extent_rectangles()  # create the extent array
    ext = ext + m  # shift back, construct the output features
    ext = Update_Geo(ext, K=kind, id_too=None, Info=info)
    #
    # ---- produce the geometry
    p = "POLYGON"
    if kind == 1:
        p = "POLYLINE"
    geometry_fc(ext, ext.IFT, p_type=p, gdb=gdb, fname=name, sr=SR)
    return "{} completed".format(out_fc)