import arcpy array = arcpy.Array([arcpy.Point(0, 0), arcpy.Point(0, 1000), arcpy.Point(1000, 1000), arcpy.Point(1000, 0) ]) polygon = arcpy.Polygon(array) cursor = arcpy.da.InsertCursor(r'C:\path\to\your\geodatabase.gdb\polygon', ['SHAPE@']) cursor.insertRow([polygon])
The code below works as expected, but fails if I substitute Lat/Longs in the arcpy.Point. Is that expected?
Solved! Go to Solution.
Can you try this?
import arcpy
fc = r'C:\path\to\your\geodatabase.gdb\polygon'
sr = arcpy.Describe(fc).spatialReference # get spatial reference
array = arcpy.Array([arcpy.Point(-111.8256, 40.691085),
arcpy.Point(-111.825347, 40.691614),
arcpy.Point(-111.824706, 40.691896),
arcpy.Point(-111.825592, 40.68703)
])
polygon = arcpy.Polygon(array,sr) # create polygon with spatial reference
cursor = arcpy.da.InsertCursor(fc, ['SHAPE@'] )
cursor.insertRow([polygon])
Much thanks! I thought it'd pick up the sr on it's own!