maptastik
2/12/2020 - 3:20 PM

Populate separate x and y fields with WGS84 coordinates of polygon centroid

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)