Model Builder - Calculate the centroid of a polygon

6705
12
Jump to solution
05-01-2013 01:13 AM
MaryMulholland
New Contributor
I would like to calculate the centroid (x and y co-ordinate) of a polygon using model builder - ArcGIS 10.1 Standard. I don't have access to the tool Feature to Point as the standard licence doesn't allow this option and there doesn't seem to be a Calculate Geometry tool within model builder. Can anyone help please
0 Kudos
12 Replies
deleted-user-ioozWOYc0nD1
New Contributor II

The code given in the answer works great, but is there a way to return latitude, longitude instead of Y, X?

0 Kudos
AbdullahAnter
Occasional Contributor III

Try add  @ DECIMALDEGREES ! at the end of line

return shape.centroid.Y@DECIMALDEGREES !
0 Kudos
deleted-user-ioozWOYc0nD1
New Contributor II

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?

0 Kudos