Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import arcpy
# Assume a feature class called polygon_fc with two separate float/double fields, x and y
with arcpy.da.UpdateCursor('polygon_fc', ['SHAPE@', 'x', 'y']) as cursor:
for row in cursor:
geom_4326 = row[0].projectAs(arcpy.SpatialReference(4326))
row[1] = geom_4326.centroid.X
row[2] = geom_4326.centroid.Y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment