calculate polygon area

Ed McNierney ed at TOPOZONE.COM
Tue Jul 18 17:22:11 EDT 2006


Mateusz -

I don't mind the Earth being spherical as much as I object to the
concept of a "square degree".  Since a "degree" is an angular
measurement, not a linear one, the "square degree" mentioned in the code
appears to refer to a patch on the surface of the sphere defined by two
perpendicular one-degree angles with their vertices at the CENTER of the
sphere.  In other words, for a given radius, one "square degree" is
indeed a constant area.  And a useful concept for game programmers (I
used to be one).

This is very confusingly similar to but different from the concept of
degrees of latitude and longitude, since a degree of longitude is a
one-degree angle with its vertex on a line between the poles, and NOT at
the center of the Earth.

It appears that the code given (it's hard to tell, given the almost
complete absence of comments) takes "latitude" and "longitude"
coordinates as inputs, and then finds the angles of the triangles inside
the defined polygon and calculates the area of those triangles using
standard spherical geometry.

If that's the case, then it is possible that the magic "square mi per
spherical degree" is the appropriate conversion factor for a roughly
spherical Earth, but I can't verify it since the code makes no effort to
explain where that constant comes from.

So it may indeed be possible that this code might produce rough and not
terribly accurate results.  I don't know how accurate Julien is trying
to be.

Julien, it would help if you could tell us how large an area you are
working with, and what kind of accuracy you need.  Mateusz's suggestion
of some equal-area projection is good, but if you don't need much
accuracy you might be able to take some shortcuts.

	- 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 4:31 PM
To: MAPSERVER-USERS at LISTS.UMN.EDU
Subject: Re: [UMN_MAPSERVER-USERS] calculate polygon area

Ed McNierney wrote:
> Mateusz -
> 
> That is some very suspicious-looking code.  It says:
> 
> "Returns the area of a spherical polygon in spherical degrees"

The function SphericalPolyArea does this job correctly.

> 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!!!

This part is another story and I agree in this matter with you.

> 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.

Julien did said nothing about projection and that he want's to get
usable values for particular area.
I understood he is looking for some simple/general solution And
calculation of spherical polygon area is such general solution, but I
agree it does no provide good quality results regarding our Mother
Earth.

BTW, this procedure comes to book for game programmers, so it assume the
Earth is spherical.

Julien, if you want to get correct results I'd suggest you to use
equal-area projection for the are of your interest.

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



More information about the mapserver-users mailing list