Hi Barend,

Thanks for replying.
I will try passing the radius of the Earth in kilometers to the strategy constructor.

Thanks.


On Mon, Apr 14, 2014 at 5:44 PM, Barend Gehrels <barend@xs4all.nl> wrote:
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@gmail.com> wrote:
Hi all,

I run the "area (with strategy)" example shown on 


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 mailing list
Geometry@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/geometry