Select to view content in your preferred language

Calculate the centroid of a polygon using field calculator

1585
2
11-10-2016 03:59 PM
AdamVajda
Deactivated User

Is it possible to calculate the centroid of a polygon using field calculator? I am using model builder, and have an empty longitude and latitude field I need to populate (with a goal of identifying the centroid for when the model later converts the polygon to a point shapefile).

I am currently using (!shape.extent.YMax! + !shape.extent.YMin!) / 2  & (!shape.extent.XMax! + !shape.extent.XMin!) / 2 to calculate lat long values, but of course this does not result in the center of the polygon unless it is a square.

0 Kudos
2 Replies
DanPatterson_Retired
MVP Emeritus

Reading geometries—Help | ArcGIS for Desktop You missed a whole section in the arcpy help... maybe Truecentroid... your choice, but have a look at what is there

JayantaPoddar
MVP Esteemed Contributor

You could also add Add Geometry Attributes—Data Management toolbox | ArcGIS for Desktop to your model for adding new geometry fields to the input features.



Think Location