Calculate area of “hand-drawn” polygon

488 Views Asked by At

I have a series of coordinates that represent a hand-drawn polygon. At the intersection, the lines slightly "overshoot," e.g.:

x   y
-24 20
-23 20
20  23
23  -23
-22 -23
-23 23
-24 24

The actual file has hundreds of coordinates. I need to calculate the area of the polygon. The traditional approach (http://www.mathsisfun.com/geometry/area-irregular-polygons.html) is inaccurate because of the overshoot. I need to either find a way to calculate the area and ignore the overshoot or crop the data so that it does not overshoot. Thank you!

2

There are 2 best solutions below

1
On

You can use a Monte-Carlo method of finding an approximate area. This involves creating a reference area and randomly throwing points all over the figure. You would then count how many points land inside the figure and how many points there are in total, divide them respectively, and then multiply by the reference area. Ergo, if you're trying to find the area of some figure $S$ with reference area $T$, $$A_{est} = \frac{\text{total }(x,y) \in S}{\text{total points used}}\times T.$$

Here are a few worked examples: http://www.mathdemos.org/mathdemos/MCArea/MCArea.html

This unfortunately only gives an approximation, but the approximation is pretty decent most of the time. The advantage is that it's quick and easy because YOU choose what $T$ can be. Obviously, $T$ can be a square/rectable since area of a rectangle with length $l$ and width $w$ is $A_{rect} = lw$.

2
On

If the vertices of the polygon have coordinates $(x_1,y_1),\dots,(x_n,y_n)$, then the area of the polygon is $$ {1 \over 2} \Big | \sum_{i=1}^{n} \det\begin{pmatrix} x_i & x_{i+1} \\ y_i & y_{i+1} \end{pmatrix} \Big | $$ where $x_{n+1}=x_1$ and $y_{n+1}=y_1$.