The area of a polygon and the shoelace formula

If the coordinates of the vertices of a polygon are known, its area can be computed by simply walking once around them1. We do it for the pentagon with vertices A(0,0)A(0, 0), B(4,0)B(4, 0), C(5,3)C(5, 3), D(2,5)D(2, 5) and E(1,2)E(-1, 2).

The shoelace formula

List the vertices counterclockwise as (x1,y1),,(xn,yn)(x_1, y_1), \ldots, (x_n, y_n), form xiyi+1xi+1yix_i y_{i+1} - x_{i+1} y_i for each adjacent pair, and add. After the last vertex one returns to the first.

S=12i=1n(xiyi+1xi+1yi)S = \frac{1}{2} \left| \sum_{i=1}^{n} (x_i y_{i+1} - x_{i+1} y_i) \right|

Working through it

Sidexiyi+1xi+1yix_i y_{i+1} - x_{i+1} y_iValue
ABAB00400 \cdot 0 - 4 \cdot 000
BCBC43504 \cdot 3 - 5 \cdot 01212
CDCD55235 \cdot 5 - 2 \cdot 31919
DEDE22(1)52 \cdot 2 - (-1) \cdot 599
EAEA(1)002(-1) \cdot 0 - 0 \cdot 200

The total is 4040, so the area is 12×40=20\dfrac{1}{2} \times 40 = 20.

What the formula means

The meaning can be traced back to the area of a triangle. The triangle formed by the origin and two points (p,q)(p, q) and (r,s)(r, s) has area 12psqr\dfrac{1}{2}|ps - qr|. Viewing each side from the origin cuts the figure into triangles; adding them with signs cancels whatever sticks out beyond the polygon as a negative triangle, and the area of the polygon itself is what remains.

Checking by cutting along diagonals

TriangleArea
ABC\triangle ABC66
ACD\triangle ACD192\dfrac{19}{2}
ADE\triangle ADE92\dfrac{9}{2}
Total2020

The answers agree.

Cautions in use

  • The vertices must be listed in the order they are traced around the figure; reordering them gives a different shape
  • No side may cross another, since a self-intersecting outline makes the areas cancel
  • The polygon need not be convex

What the sign means

The sign of the value before the absolute value records the orientation: positive counterclockwise and negative clockwise. Computers also use that sign to decide which side of a polygon faces outward.

The five lines on the graph are the five sides, and the large dots are the five vertices.

  1. Shoelace formula, Wikipedia