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

- 1 person found this helpfulHi Mary,

You can do this using the Calculate Field tool. Here is an example how to set it up.

[ATTACH=CONFIG]23900[/ATTACH]

To do the Y centroid, simply change the line:return shape.centroid.X

to:return shape.centroid.Y

Apologies!! I am coming into this thread several years too late. I am literally trying to accomplish the exact same thing but I can't get my python code right...I see your original attachment is no longer...I've followed the steps in the scrn shot of the calcutalor but I am so new to python...i'm probably missing an exclamation mark or something ridiculous....here's hoping you can help me as well. I've been googling python snippets all day and can't seem to find what works.

thanks as always

Lana

lana donaldson, post your code and we can help. Or, better yet, start a new question, since this one is answered.

- If you create two new fields in your feature table make the double precision fields. One for X one for Y.

In an edit session right click on the X field and choose calculate geometry. From the drop down menu choose X coordinate of centroid. Then do the same for YI 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

Apologies!! I am coming into this thread several years too late. I am literally trying to accomplish the exact same thing but I can't get my python code right...I see your original attachment is no longer...I've followed the steps in the scrn shot of the calcutalor but I am so new to python...i'm probably missing an exclamation mark or something ridiculous....here's hoping you can help me as well. I've been googling python snippets all day and can't seem to find what works.

thanks as always

Lana

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

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?

You can do this using the Calculate Field tool. Here is an example how to set it up.

[ATTACH=CONFIG]23900[/ATTACH]

To do the Y centroid, simply change the line:

to: