Hello, I am working on a script that produces a polygon grid from a series of irregularly spaced points (hence why I can't use fishnet).
I have managed to produce the desired grid but am unable to assign a spactial reference to the grid.
I have tried a number of ways such as assigning a Spactial Reference. I've tried to assign it to the individual points using a for loop:
PointsList=[]
for n in coordList:
array=[]
for coords in n:
point=arcpy.Point(coords[0],coords[1])
ptGeometry=arcpy.PointGeometry(point,arcpy.SpatialReference(factoryCode))
array.append(ptGeometry)
PointsList.append(array)
features = []
for feature in PointsList:
#Create a Polygon object based on the array of points
#Append to the list of Polygon objects
features.append(
arcpy.Polygon(
arcpy.Array(*corner)) for corner in feature)
arcpy.CopyFeatures_management(features, outputName)
Or to the polygon durring its construction:
features = []
for feature in coordList:
# Create a Polygon object based on the array of points
# Append to the list of Polygon objects
features.append(
arcpy.Polygon(
arcpy.Array([arcpy.Point(*coords) for coords in feature]), arcpy.SpatialReference(factoryCode)))
arcpy.CopyFeatures_management(features, outputName)
But both ways are giving me a runtime error.
I was wondering if it would be best to first create a feature class and then creat my polygons but I don't know how to write polygons to feature classes in python.
If someone could provide guidance it would be much apprechiated.