[Mapserver-users] area Calculation in polygon-shapes

woodbri at swoodbridge.com woodbri at swoodbridge.com
Mon Feb 2 13:45:35 EST 2004


Ack, you are right when applying it to GIS problems. In fact if you 
use it with lat/long data you will end up computing a result in 
degrees squared! Not the most intuitive units :)

Which points out an important fact that you need to be aware of for 
any solution - you need to know the limits and assumptions of a 
solution before you apply it to a problem. For example are you trying 
to compute the area of a surface contained within a polygon, How is 
the polygon projected onto the surface? Is the surface smooth or has 
it terrain? etc, etc.

If you don't care about most or all of this, my solution below might 
work for some simple cases, but Norman's links will give you more 
generalized or other specific solution that may be more valuable.

-Steve

On 2 Feb 2004 at 11:07, Norman Vine wrote:

> > 
> > 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
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
> 





More information about the mapserver-users mailing list