Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

Cheers!

share|improve this question
add comment

2 Answers

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

http://support.esri.com/en/knowledgebase/techarticles/detail/27851

http://forums.esri.com/Thread.asp?c=9&f=85&t=132922

You will need to transform to meters first.

share|improve this answer
4  
actually there is another function in geometry getGeodesicArea() wich returns aproximated area in square meters! –  vaske May 13 '11 at 9:10
1  
@vaske: Is your comment the answer to your question? –  underdark May 13 '11 at 9:25
2  
This is OpenLayers not ArcMap. –  CaptDragon May 13 '11 at 13:59
    
I know that, but the question was how to convert square degrees to square meters and I suggested to do it before getting area. –  Mykolas Simutis May 13 '11 at 14:24
    
@underdark yes that's the answer :) –  vaske May 16 '11 at 6:18
show 1 more comment

Try this:

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

var kmArea = area * 1000;

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

EDIT: Sorry, don't multiply by 1000 DIVIDE by 1000000.

var kmArea = area / 1000000;
share|improve this answer
    
I think you need to divide by 1e6 to get square km not multiply by 1000. –  iant 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 –  iant 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 :-) –  iant May 13 '11 at 15:09
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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