Understanding the shoelace formula polygon area calculator — concept and principle
The shoelace formula (also called Gauss’s area formula or the surveyor’s formula) finds the area of any simple polygon from the coordinates of its corners, without splitting it into triangles by hand. Enter the vertices in order around the boundary, and the calculator returns the area, the perimeter, the centroid (the balance point of the region) and the direction in which the vertices were listed. It is used for survey plots, floor plans, GIS and computer graphics.
How it is calculated
For vertices (x₁, y₁), …, (xₙ, yₙ), with the list wrapping back to the first point:
- Signed double area: S = Σ (xᵢyᵢ₊₁ − xᵢ₊₁yᵢ)
- Area: A = |S| ÷ 2
- Perimeter: the sum of the distances between consecutive vertices, including the closing edge
- Centroid: Cx = Σ (xᵢ + xᵢ₊₁)(xᵢyᵢ₊₁ − xᵢ₊₁yᵢ) ÷ (3S), and Cy likewise with y
- Orientation: S > 0 means counter-clockwise, S < 0 clockwise
Coordinates share one unit; the area is in that unit squared.
The principle
Each term xᵢyᵢ₊₁ − xᵢ₊₁yᵢ is twice the signed area of the triangle formed by the origin and one edge. Walking around the polygon, triangles on the far side are added and those on the near side are subtracted, so everything outside the polygon cancels and only the enclosed area remains. The sign records the walking direction, which is why the absolute value is taken. Writing the coordinates in two columns and multiplying diagonally looks like lacing a shoe, which gives the formula its name.
Worked example
- Input: (0, 0), (4, 0), (4, 3), (0, 3), a 4 × 3 rectangle.
- Terms: 0×0 − 4×0 = 0; 4×3 − 4×0 = 12; 4×3 − 0×3 = 12; 0×0 − 0×3 = 0. S = 24.
- Area: |24| ÷ 2 = 12.
- Perimeter: 4 + 3 + 4 + 3 = 14.
- Centroid: Cx = (4×0 + 8×12 + 4×12 + 0×0) ÷ 72 = 144 ÷ 72 = 2, Cy = (0 + 3×12 + 6×12 + 0) ÷ 72 = 1.5, so (2, 1.5).
- S is positive, so the order is counter-clockwise.
How to read the result
The centroid is the point where a flat cut-out of the shape would balance; for a rectangle it is the centre. A negative signed area simply means the points were given clockwise; the area itself is unaffected. Survey drawings often list vertices clockwise, and screen coordinates with y pointing down reverse the reported orientation.
Common mistakes
- Listing vertices out of order, which creates crossing edges and a wrong area.
- Entering a self-intersecting shape such as a figure eight; its parts cancel.
- Mixing latitude and longitude degrees with metres; project to a flat grid first.
Frequently asked questions
Does the starting vertex matter?
No. Any starting point gives the same area, as long as the vertices follow the boundary in order.
Can I use it for a polygon with a hole?
Compute the outer boundary and the hole separately and subtract the hole’s area.
Sources: B. Braden, The Surveyor’s Area Formula, The College Mathematics Journal 17(4), 1986, 326–337 · J. O’Rourke, Computational Geometry in C, 2nd ed., Cambridge University Press (polygon area and centroid)