Boost logo

Geometry :

Subject: Re: [geometry] Units of area (with strategy)
From: Barend Gehrels (barend_at_[hidden])
Date: 2014-04-14 16:44:07


Hi Fernando,

Fernando Pelliccioni wrote On 14-4-2014 20:36:
> Any comments?
>
> Thanks!
>
>
> On Mon, Apr 7, 2014 at 10:28 AM, Fernando Pelliccioni
> <fpelliccioni_at_[hidden] <mailto:fpelliccioni_at_[hidden]>> wrote:
>
> Hi all,
>
> I run the "area (with strategy)" example shown on
>
> http://www.boost.org/doc/libs/1_55_0/libs/geometry/doc/html/geometry/reference/algorithms/area/area_2_with_strategy.html
>
> I'm interested in getting the geodetic area (the second one of the
> code below)
>
>
> #include <iostream>
> #include <boost/geometry.hpp>
> #include <boost/geometry/geometries/polygon.hpp>
> #include <boost/geometry/io/wkt/wkt.hpp>
>
> namespace bg = boost::geometry;
>
> int main()
> {
> // Calculate the area of a spherical polygon (for latitude: 0
> at equator)
> bg::model::polygon<bg::model::point<float, 2,
> bg::cs::spherical_equatorial<bg::degree> > > sph_poly;
> bg::read_wkt("POLYGON((0 0,0 45,45 0,0 0))", sph_poly);
> double area = bg::area(sph_poly);
> std::cout << "Area: " << area << std::endl;
>
> return 0;
> }
>
>
> The code above prints out:
> Area: 0.339837
>
> In this case, what is the unit of the area?
>
> The documentation states that:
> Returns the area on a unit sphere (or another sphere, if specified
> as such in the constructor of the strategy)
>
> Sorry, but my knowledge of geography is limited.
> How can I transform that number to square kilometers, square
> miles, ...?
>
> Thank you very much.
>

You can convert this to the Earth-considered-as-a-perfect-sphere by
passing the radius of the Earth in the strategy. This is more or less
what the documentation says. If you pass it in Kilometers you will get
square kilometers, if you pass miles you get miles back.

However, the Earth is not a perfect sphere so the above is a rough
approximation. At this moment we don't have anything better yet, because
most of the Geographic Coordinate System is still in extensions and does
not contain all functionality yet.

Regards, Barend



Geometry list run by mateusz at loskot.net