Python arcpy.Array() Examples

The following are 7 code examples of arcpy.Array(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module arcpy , or try the search function .
Example #1
Source File: CreateCustomGrid.py    From ArcPy with GNU General Public License v2.0 6 votes vote down vote up
def vertical(TLX, TRX, TLY, TRY, BLX, BRX, BLY, BRY, divisions):

    count = 1.0
    while count < divisions:
        a         = float(TLX*((divisions-count)/divisions) + TRX*(count/divisions)) + float(overflow)
        b         = float(TLY*((divisions-count)/divisions) + TRY*(count/divisions)) + float(overflow)

        c         = float(BLX*((divisions-count)/divisions) + BRX*(count/divisions)) - float(overflow)
        d         = float(BLY*((divisions-count)/divisions) + BRY*(count/divisions)) - float(overflow)

        T2B       = arcpy.Array([arcpy.Point(a, b), arcpy.Point(c, d)])
        T2B_line  = arcpy.Polyline(T2B)

        insert_cursor.insertRow((T2B_line,))

        count += 1.0 
Example #2
Source File: CreateCustomGrid.py    From ArcPy with GNU General Public License v2.0 6 votes vote down vote up
def horizontal(TLX, TRX, TLY, TRY, BLX, BRX, BLY, BRY, divisions):

    count = 1.0
    while count < divisions:
        a         = float(TLX*((divisions-count)/divisions) + BLX*(count/divisions)) - float(overflow)
        b         = float(TLY*((divisions-count)/divisions) + BLY*(count/divisions)) - float(overflow)

        c         = float(TRX*((divisions-count)/divisions) + BRX*(count/divisions)) + float(overflow)
        d         = float(TRY*((divisions-count)/divisions) + BRY*(count/divisions)) + float(overflow)

        L2R       = arcpy.Array([arcpy.Point(a, b), arcpy.Point(c, d)])
        L2R_line  = arcpy.Polyline(L2R)

        insert_cursor.insertRow((L2R_line,))

        count += 1.0 
Example #3
Source File: arcapi.py    From arcapi with GNU Lesser General Public License v3.0 6 votes vote down vote up
def make_poly_from_extent(ext, sr):
    """Make an arcpy polygon object from an input extent object.,Returns
    a polygon geometry object.

    Required:
    ext -- extent object
    sr -- spatial reference

    Example
    >>> ext = arcpy.Describe(fc).extent
    >>> sr = 4326  #WKID for WGS 84
    >>> poly = make_poly_from_extent(ext, sr)
    >>> arcpy.CopyFeatures_management(poly, r'C:\Temp\Project_boundary.shp')
    """
    array = arcpy.Array()
    array.add(ext.lowerLeft)
    array.add(ext.lowerRight)
    array.add(ext.upperRight)
    array.add(ext.upperLeft)
    array.add(ext.lowerLeft)
    return arcpy.Polygon(array, sr) 
Example #4
Source File: datasetExtentToFeatures.py    From sample-gp-tools with Apache License 2.0 5 votes vote down vote up
def execute(in_datasets, out_fc):
    # use gcs as output sr since all extents will fit in it
    out_sr = arcpy.SpatialReference("WGS 1984")

    in_datasets = in_datasets.split(";")

    arcpy.CreateFeatureclass_management(os.path.dirname(out_fc),
                                        os.path.basename(out_fc),
                                        "POLYGON",
                                        spatial_reference=out_sr)

    arcpy.AddField_management(out_fc, "dataset", "TEXT", 400)

    # add each dataset's extent & the dataset's name to the output
    with arcpy.da.InsertCursor(out_fc, ("SHAPE@", "dataset")) as cur:

        for i in in_datasets:
            d = arcpy.Describe(i)
            ex = d.Extent
            pts = arcpy.Array([arcpy.Point(ex.XMin, ex.YMin),
                              arcpy.Point(ex.XMin, ex.YMax),
                              arcpy.Point(ex.XMax, ex.YMax),
                              arcpy.Point(ex.XMax, ex.YMin),
                              arcpy.Point(ex.XMin, ex.YMin),])

            geom = arcpy.Polygon(pts,  d.SpatialReference)

            if d.SpatialReference != out_sr:
                geom = geom.projectAs(out_sr)
            cur.insertRow([geom, d.CatalogPath]) 
Example #5
Source File: CreateQQSections.py    From ArcPy with GNU General Public License v2.0 5 votes vote down vote up
def qq(TLX, TRX, TLY, TRY, BLX, BRX, BLY, BRY, divisions):

    count = 1.0
    while count < divisions:
        a         = float(TLX*((divisions-count)/divisions) + TRX*(count/divisions)) + float(overflow)
        b         = float(TLY*((divisions-count)/divisions) + TRY*(count/divisions)) + float(overflow)

        c         = float(BLX*((divisions-count)/divisions) + BRX*(count/divisions)) - float(overflow)
        d         = float(BLY*((divisions-count)/divisions) + BRY*(count/divisions)) - float(overflow)

        e         = float(TLX*((divisions-count)/divisions) + BLX*(count/divisions)) - float(overflow)
        f         = float(TLY*((divisions-count)/divisions) + BLY*(count/divisions)) - float(overflow)

        g         = float(TRX*((divisions-count)/divisions) + BRX*(count/divisions)) + float(overflow)
        h         = float(TRY*((divisions-count)/divisions) + BRY*(count/divisions)) + float(overflow)

        T2B       = arcpy.Array([arcpy.Point(a, b), arcpy.Point(c, d)])
        L2R       = arcpy.Array([arcpy.Point(e, f), arcpy.Point(g, h)])

        T2B_line  = arcpy.Polyline(T2B)
        L2R_line  = arcpy.Polyline(L2R)

        insert_cursor.insertRow((T2B_line,))
        insert_cursor.insertRow((L2R_line,))

        count += 1.0 
Example #6
Source File: CreateQSections.py    From ArcPy with GNU General Public License v2.0 5 votes vote down vote up
def q(TLX, TRX, TLY, TRY, BLX, BRX, BLY, BRY, divisions):

    count = 1.0
    while count < divisions:
        a         = float(TLX*((divisions-count)/divisions) + TRX*(count/divisions)) + float(overflow)
        b         = float(TLY*((divisions-count)/divisions) + TRY*(count/divisions)) + float(overflow)

        c         = float(BLX*((divisions-count)/divisions) + BRX*(count/divisions)) - float(overflow)
        d         = float(BLY*((divisions-count)/divisions) + BRY*(count/divisions)) - float(overflow)

        e         = float(TLX*((divisions-count)/divisions) + BLX*(count/divisions)) - float(overflow)
        f         = float(TLY*((divisions-count)/divisions) + BLY*(count/divisions)) - float(overflow)

        g         = float(TRX*((divisions-count)/divisions) + BRX*(count/divisions)) + float(overflow)
        h         = float(TRY*((divisions-count)/divisions) + BRY*(count/divisions)) + float(overflow)

        T2B       = arcpy.Array([arcpy.Point(a, b), arcpy.Point(c, d)])
        L2R       = arcpy.Array([arcpy.Point(e, f), arcpy.Point(g, h)])

        T2B_line  = arcpy.Polyline(T2B)
        L2R_line  = arcpy.Polyline(L2R)

        insert_cursor.insertRow((T2B_line,))
        insert_cursor.insertRow((L2R_line,))

        count += 1.0 
Example #7
Source File: arc_restapi.py    From restapi with GNU General Public License v2.0 5 votes vote down vote up
def asShape(self):
        """Returns JSON as arcpy.Geometry() object."""
        if self.geometryType != ESRI_ENVELOPE:
            return arcpy.AsShape(self.json, True)
        else:
            ar = arcpy.Array([
                arcpy.Point(self.json[XMIN], self.json[YMAX]),
                arcpy.Point(self.json[XMAX], self.json[YMAX]),
                arcpy.Point(self.json[XMAX], self.json[YMIN]),
                arcpy.Point(self.json[XMIN], self.json[YMIN])
            ])
            return arcpy.Polygon(ar, arcpy.SpatialReference(self.spatialReference))