calculate polygon area

Ed McNierney ed at TOPOZONE.COM
Tue Jul 18 15:35:33 EDT 2006


Mateusz -

That is some very suspicious-looking code.  It says:

"Returns the area of a spherical polygon in spherical degrees"  and then
displays the area in "Square Miles" by using these constants:

double
    SqMi= 273218.4, /* Square mi per spherical degree. */
    SqKm= 707632.4; /* Square km per spherical degree. */

and multiplies the area in "spherical degrees" by 273218.4!!!

I cannot figure out what the constant 273218.4 is supposed to represent.
Over there in Warsaw one degree of latitude is 69.14 statute miles, and
one degree of longitude is 42.53 statute miles, so there are 2940.52
square miles in that "square degree".  At my house there are 3519.33
square miles in a "square degree", and down in Quito there are 4752.54
square miles in that same "square degree".

Even overlooking the minor error introduced with a sphere rather than an
ellipsoid, I am skeptical that this code will actually do anything
useful.

	- Ed

Ed McNierney
President and Chief Mapmaker
TopoZone.com / Maps a la carte, Inc.
73 Princeton Street, Suite 305
North Chelmsford, MA  01863
ed at topozone.com
(978) 251-4242 

-----Original Message-----
From: UMN MapServer Users List [mailto:MAPSERVER-USERS at LISTS.UMN.EDU] On
Behalf Of Mateusz Loskot
Sent: Tuesday, July 18, 2006 9:33 AM
To: MAPSERVER-USERS at LISTS.UMN.EDU
Subject: Re: [UMN_MAPSERVER-USERS] calculate polygon area

On 7/18/06, Julien Bessiere <julien.63 at free.fr> wrote:
> So my questions is :
>
> 1- Does phpmapscript has a function to calculate area (something like 
> distanceToPoint(pointObj poPoint))?

I have no idea.

>> 2- If no, how to calculate area wiht lat long coordinates?

You need to calculate area of spherical polygon.
Here you can find C code for this purpose

http://www.acm.org/pubs/tog/GraphicsGems/gemsiv/sph_poly.c

I hope you will be able to rewrite it to PHP.

Best regards
--
Mateusz Loskot
http://mateusz.loskot.net



More information about the mapserver-users mailing list