How To: Calculate feature centroids
Feature centroids can be calculated in several ways. Depending on how the centroid needs to calculated, there are several possible methods: calculate the features' central XY coordinates, use the Feature to Point tool, or use Python to retrieve centroid coordinates. Instructions provided below describe these methods.
- Calculate the x,y coordinates of the feature using Calculate Geometry
This method uses the Calculate Geometry function to find the latitude (y-coordinate of the centroid) and longitude (x-coordinate) of the centroids and constructs an XY Event Layer to display them: How To: Find the centroid of polygons using Calculate Geometry.
- Use the Feature To Point (Data Management) tool
This method uses the center of gravity of the polygon; the geometric center of a feature. For line, polygon, or three-dimensional features, it is the center of mass (or center of gravity) and may fall inside the feature or outside the feature. For multipoint, polyline, or polygon feature classes with multiple parts, the centroid is computed using the weighted mean center of all feature parts.
Note: The Feature To Point tool is only available at the Advanced Desktop or ArcInfo, license level.The Feature To Point tool is used to create a new feature class containing points generated from the representative locations of input features. The algorithms for the specific calculation are proprietary, but there are two basic concepts used.
The tool calculates the centroid of multipoint, line, or polygon input using a center of gravity-based algorithm. The center of gravity calculation uses the geometric center model to output the new point feature class. For lines, polygons, or three-dimensional features, it is the center of mass (center of gravity) and may fall inside or outside the feature. For multipoint, polylines, or polygons with multiple parts, it is computed using the weighted mean center of all feature parts.
Within the tool parameters there is an option to calculate the centroid that falls within the feature boundaries; this option can be enabled by checking the box for 'inside'. Enabling this parameter forces the tool to calculate a centroid that is inside the feature boundaries, if it originally falls outside the boundaries the point will be adjusted to what is considered the center of gravity within the boundaries.
- Use Python to calculate and build centroid points
In the following sample, the Data Access Module is used to retrieve the centroid coordinates using the SHAPE@XY token. These coordinates are then used to build point geometry, which is then written to a new feature class.
Note: The Data Access cursors are available only at ArcGIS 10.1 and higher. See Reading Geometries and Writing Geometries for alternative workflows for version 10.x.
Code: import arcpy input_fc = "C:\\temp\\geodatabase.gdb\\states" output_fc = "C:\\temp\\geodatabase.gdb\\state_centroids" cursor = arcpy.da.SearchCursor(input_fc, "SHAPE@XY") centroid_coords =  for feature in cursor: centroid_coords.append(feature) point = arcpy.Point() pointGeometryList =  for pt in centroid_coords: point.X = pt point.Y = pt pointGeometry = arcpy.PointGeometry(point) pointGeometryList.append(pointGeometry) arcpy.CopyFeatures_management(pointGeometryList, output_fc)