calculate polygon area

Julien Bessiere julien.63 at FREE.FR
Wed Jul 19 07:43:32 PDT 2006


Hi Ed, Mateusz and Steeve,
First of all, thanks for your answers.
Then, it's my turn to answer. So :

>>>>>>>>>"If you have GEOS support you can try to use the geos msGEOSArea()
function."
* my mapserver installation does not support GEOS.

>>>>>>>>>"If you use a useful output projection (such as UTM or a standard
regional projection) then the math should be quite simple."
* You mean that if I should use 'PROJECTION "init=epsg:2029" END' instead of
'PROJECTION  "init=epsg:4326" END' as output format in my map file and use the
coordinate to calculate the area ?

>>>>>>>>>"it would help if you could tell us how large an area you are
working with, and what kind of accuracy you need."
- I'm working for the Smithsonian tropical Research Institut in Panama. The aim
is to estimate the aera and I don't think we need a very high accuracy level.
But the range could be quite large. I
guess the polygon area could stretch from about 20 km² up to 300 000 km². Is it
possible to evaluate the miscalculation range?

>>>>>>>>"The dev version of MapServer (which is quite stable) now has full
support for GEOS operators in MapScript including a getArea() method"
* Thanks for all this work done . It's good to know and I gonna think about it.

thanks again for your advices

Julien

Selon Ed McNierney <ed at TOPOZONE.COM>:

> 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