I get a multypolygon from my web service and want to calculate the area of that polygon. I was trying to use this piece of code:

var poly = new OpenLayers.Geometry.MultiPolygon(poligon);
var area = geom.getArea();

But that returns the area in square degrees. The projection is EPSG:3243.
I then tried to use

OpenLayers. Layer. SphericalMercator

But that didn't help me a lot.

Is there any other solution or some other hint?


Try this:

var poly = new OpenLayers.Geometry.MultiPolygon(poligon);
var area = geom.getGeodesicArea();

var kmArea = area / 1000000;

Reference: http://dev.openlayers.org/docs/files/OpenLayers/Geometry/Polygon-js.html#OpenLayers.Geometry.Polygon.getGeodesicArea

  • 1
    I think you need to divide by 1e6 to get square km not multiply by 1000. – Ian Turton May 13 '11 at 14:42
  • Not sure, but wouldn't it be divide by 1000 since the function returns square meters? I definitely goofed by multiplying by 1000 but what i meant was divide by 1000. – CaptDragon May 13 '11 at 14:49
  • 1
    there are 1000m in a Km so 1000*1000 sq m in a sq km – Ian Turton May 13 '11 at 14:54
  • +1 Okay i follow you, excuse my math disorder, but then it would be area / 1000000? – CaptDragon May 13 '11 at 15:02
  • 2
    that's what I said :-) – Ian Turton May 13 '11 at 15:09

as far as I know it is not possible. Some references to it:



You will need to transform to meters first.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.