FAQ: How does ArcView calculate aPolygon.ReturnCenter?
How does ArcView calculate aPolygon.ReturnCenter?
In computational geometry, there are different approaches to calculate the centroid of a polygon, each with its own pros and cons. ArcView uses the following method:
The center of a polygon is determined by taking the center point of the polygon's bounding box. If the center of the polygon's bounding box does not fall inside the polygon itself (one example would be a crescent-shaped polygon), the point is moved in the X direction until it enters into the polygon (let's call this "Point1"). The point is then moved in the same direction, along the X axis, until it exits the polygon (let's call this "Point2"). The centroid is calculated to be halfway between Point1 and Point2, on the same X axis. For complex polygons that have more than one pair of polygon outlines that cross the X-axis, each pair of outlines is compared to see which pair creates the widest length along the X-axis. Then, the centroid is calculated to be halfway between the points where this pair of outlines crosses the X-axis.
The center of the multi-part group's bounding box is tested to see whether it falls inside any of the polygon parts or not. If it does, that point is designated as the centroid. The point must fall inside this center polygon part, not merely inside the bounding box of this center polygon part.
If the center of the group's bounding box does not fall within any polygon part, the single-part polygons method described above is performed on the polygon part that has the largest area. The resulting point is designated as the centroid of the multi-part polygon.