Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Algorithm for Area of a closed polygon.

Re: Algorithm for Area of a closed polygon.

To: Ted Hill <>
Subject: Re: Algorithm for Area of a closed polygon.
From: "Demian M. Nave" <>
Date: Wed, 12 Nov 2003 21:23:16 -0500 (EST)
Cc: <>
In-reply-to: <>
References: <>
Reply-to: Demian Nave <>

Hi Ted,

I want to be able to calculate the area inside a closed many-sided polygon.

As long as your polygon has no self-crossings or internal holes, this algorithm is probably the simplest. It will return twice the signed area of your polygon:

Let 'vertices' be an array of N pairs (x,y), indexed from 0
Let 'area' = 0.0
for i = 0 to N-1, do
  Let j = (i+1) mod N
  Let area = area + vertices[i].x * vertices[j].y
  Let area = area - vertices[i].y * vertices[j].x
end for
Return 'area'

If the vertices of your polygon are specified in counter-clockwise order (i.e. by the right-hand rule), then the area will be positive. Otherwise, the area will be negative, assuming the polygon has non-zero area to begin with.

Hope this helps. Send another note to the mailing list if not. :-)

Cheers, Demian

Demian M. Nave              |        | Ph 412 268-4574
Pgh. Supercomputing Center  |   | Fx 412 268-8200-
4400 Fifth Avenue           | "When your work speaks for itself, don't
Pittsburgh, PA 15213        |  interrupt." - Kanin

The compgeom mailing lists:

see or send mail to with the line:

send readme

Now archived at

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.