This sample creates two discrete polygons as a shapefile called x_shape.shp in the c:\temp directory from input coordinates. Recorded here so I don't forget.
import arcpy
from arcpy import env
env.overwriteOutput = True
coords = [
[[0,0],[0,1],[1,1],[1,0]],
[[1.25,1.25], [1.25,1.75],[1.75,1.75],[1.75,1.25]]
]
pnt = arcpy.Point()
array = arcpy.Array()
features = []
for a_feature in coords:
for xy in a_feature:
pnt.X = xy[0]
pnt.Y = xy[1]
array.add(pnt)
array.add(array.getObject(0))
polygon = arcpy.Polygon(array)
array.removeAll()
features.append(polygon)
arcpy.CopyFeatures_management(features, "c:/temp/x_shape.shp")
No comments:
Post a Comment