FAQ: What algorithm is used by ArcGIS to determine a polygon's area?
What algorithm is used by ArcGIS to determine a polygon's area?
The algorithm used by ArcGIS to calculate area is called the shoelace formula or Gauss's area formula. Esri uses a normalized form of this formula to preserve numeric precision.
The algorithm calculates the area for each ring (part) in a polygon. If the ring is clockwise (outer ring) the area is positive, and if the ring is counterclockwise (inner ring) the value is negative.
A partial sum of a trapezoid's area is used where:
cPoints - Number of points in the ring
points - Array of point structure, the structure as X and Y as attributes
yOrigin - Double equal to the Y value of the last point (cpoints-1)
The first trapezoid's area is:
For each point starting at index 1:
partialSums[j] = (points[j+1].x - points[j-1].x) * (points[j].y - yOrigin)
If the ring contains nonlinear segments, such as Circular Arc, Elliptic Arc, and Bezier Curve, a correction of the area is applied for each trapezoid.
The final area of the ring is:
The final area of the polygon is:
Here is an example with the following points (one square ring) zz:
X0 = 0 ; Y0 = 0
X1 = 0 ; Y1 = 10
X2 = 10 ; Y2 = 10
X3 = 10 ; Y3 = 0
X4 = 0 ; Y4 = 0
partialSums(0) = (X0 - X4) * (Y0 - Y4) = (0 - 0) * (0 - 0) = 0
partialSums(1) = (X2 - X0) * (Y1 - Y4) = (10 - 0) * (10 - 0) = 100
partialSums(2) = (X3 - X1) * (Y2 - Y4) = (10 - 0) * (10 - 0) = 100
partialSums(3) = (X4 - X2) * (Y3 - Y4) = (0 - 10) * (0 - 0) = 0
There is no correction to apply in this case because only lines are used.
For ArcObjects developers, area is defined as IArea::Area.