Solved! Go to Solution.
The code given in the answer works great, but is there a way to return latitude, longitude instead of Y, X?
Try add @ DECIMALDEGREES ! at the end of line
return shape.centroid.Y@DECIMALDEGREES !
Thanks for the suggestion, Abdullah. However, doing so in the Code Block returns a Python syntax error (000989):
Used the modifier in the Expression [yCentroid(!Shape@DECIMALDEGREES!] returned a different Python error (000539), indicating that there is an invalid field used, namely "the distance method is not a valid method of the geometry object".
I'm using NAD_1983_StatePlane_Colorado_South_FIPS_0503_Feet.
This calculation works fine using Calculate Geometry (from the attribute table):
Is there a way to view the log of the centroid calc process used by the Calculate Geometry tool?