HomeMath › Polygon Area Calculator (Shoelace Formula)

Polygon Area Calculator (Shoelace Formula)

Computes the area of a simple polygon from its vertex coordinates with the shoelace (Gauss) formula, plus its perimeter, centroid, orientation and whether it is convex.

When to use

You have the (x, y) coordinates of a polygon's vertices in order around its boundary and need its area, centroid or perimeter, e.g. a land parcel, floor plan or map shape.

Do not use when: The polygon is regular and you know only its side length (use regular-polygon), it is a triangle given by side lengths (use triangle-area), or the edges cross each other (the shoelace formula is not valid for self-intersecting polygons).

Formula

A = ½ |Σᵢ (xᵢ·yᵢ₊₁ − xᵢ₊₁·yᵢ)| (indices wrap around); perimeter = Σ √((xᵢ₊₁ − xᵢ)² + (yᵢ₊₁ − yᵢ)²); centroid = (Σ (xᵢ + xᵢ₊₁)·cᵢ, Σ (yᵢ + yᵢ₊₁)·cᵢ) / (6·A_signed) with cᵢ = xᵢ·yᵢ₊₁ − xᵢ₊₁·yᵢ

Inputs

ParameterTypeUnitRequiredDescription
pointsstring_listyesVertices as x,y pairs in boundary order (clockwise or counter-clockwise), at least 3, e.g. 0,0 4,0 4,3 0,3. A repeated first point at the end is ignored.

Outputs

OutputTypeUnitDescription
areanumber|Σ (xᵢ·yᵢ₊₁ − xᵢ₊₁·yᵢ)| / 2 in the coordinate unit squared.
perimeternumberSum of the edge lengths, including the closing edge.
centroid_xnumberx of the area centroid, Σ (xᵢ + xᵢ₊₁)(xᵢ·yᵢ₊₁ − xᵢ₊₁·yᵢ) / (6·A).
centroid_ynumbery of the area centroid.
centroidstringThe centroid as a coordinate pair, e.g. '(2, 1.5)'.
is_convexbooleantrue when every turn along the boundary is in the same direction.
orientationstring'counter-clockwise' (positive signed area) or 'clockwise'.
vertex_countintegerVertices used after dropping a repeated closing point.

Example

Rectangle 4 × 3: {"points":["0,0","4,0","4,3","0,3"]}{"area":12,"perimeter":14,"centroid_x":2,"centroid_y":1.5,"centroid":"(2, 1.5)","is_convex":true,"orientation":"counter-clockwise","vertex_count":4}

Pentagon (3,4) (5,11) (12,8) (9,5) (5,6): {"points":["3,4","5,11","12,8","9,5","5,6"]}{"area":30,"perimeter":26.090056,"centroid_x":7.166667,"centroid_y":7.611111,"is_convex":false,"orientation":"clockwise","vertex_count":5}

GET https://tttkmbb.com/api/v1/calculate/polygon-area?points=0%2C0%2C4%2C0%2C4%2C3%2C0%2C3

Machine access

Sources

FAQ

Does the vertex order matter?

The vertices must follow the boundary (either direction); listing them in a different order describes a different, possibly self-intersecting, polygon. Clockwise input only changes the sign of the signed area, which is reported as orientation.

Can I use latitude/longitude?

Only for small areas after projecting to metres (e.g. UTM); degrees of longitude are not the same length as degrees of latitude, so raw coordinates give wrong areas.

Related calculators