Created
February 12, 2020 15:20
-
-
Save maptastik/4f92dd08503f6f334004108736aff579 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
cursor.updateRow(row) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment