[Mapserver-users] area Calculation in polygon-shapes

Norman Vine nhv at cape.com
Mon Feb 2 11:07:01 EST 2004


> 
> It is easy to calculate just get the polygon shape object and extract 
> the polygon vertices. Then walk through the line segment and sum the 
> area under the line segment. Or if the vertex points are in array v 
> then in sudo-code:
> 
> area = 0;
> for (i=1; i<numPoints; i++) {
>   area = area + (v[i].x - v[i-1].x)*(v[i-1].y + (v[i].y - v[i-
> 1].y)/2.0);
> }
> // and close the gap if any between the last and the first
> area = area + (v[0].x - v[numPoints-1].x)*(v[numPoints-1].y + (v[0].y 
> - v[numPoints-1].y)/2.0);


Note that this is a 'flat earth' solution and the correspondence
of the solution obtained with what a surveyor might measure on 
the actual 'ground' is *very* dependent on the size of the area, 
it's location and the projection method used.

For example if a latlon representation of the points is used
this will be ~accurate only for small areas near the equator.

http://math.rice.edu/~pcmi/sphere/
http://www.geodyssey.com/papers/ggelare.html

Cheers

Norman



More information about the mapserver-users mailing list