Calculate area of geometry

4130
1
11-20-2012 09:04 AM
danielconrad
New Contributor
Hi,

I need to calculate the area of a geometry whose spatial reference is WGS84.  I did not find a geodesicArea method on the GeometryEngine class, so I went to use the calculateArea2D method in the Geometry class.  This method says:

"If the spatial reference is a Geographic Coordinate System (WGS84) then the 2D area calculation is defined in angular units".

I want to convert the output of this method to acres, but I am having trouble determining the angular unit of the output.  AngularUnit.Code lists 10 different angular units.

Does anyone know what the unit is for the output of the calculateArea2D method?

Thanks
0 Kudos
1 Reply
MarkBaird
Esri Regular Contributor
I would try to project your geometry into a spatial reference with a managable unit (like metres)

So my polygon below is in WGS84.  I project it into web mercator and then I have a more useful area unit

        Polygon polygon = new Polygon();
        polygon.startPath(25, 5.59);
        polygon.lineTo(13.42, 3.92);
        polygon.lineTo(12.3, 23.3);
        polygon.lineTo(38.2, 22.9);
        polygon.closePathWithLine();

        SimpleLineSymbol outline = new SimpleLineSymbol(
            new Color(0, 200, 0), 3, SimpleLineSymbol.Style.DASH_DOT_DOT);
        SimpleFillSymbol symbol = new SimpleFillSymbol(new Color(200, 0, 0, 120), outline);
        Graphic graphic = new Graphic(polygon, symbol);
        graphicsLayer.addGraphic(graphic);
       
        //web mercator works in meters
        SpatialReference webMercator = SpatialReference.create(3857);
       
        //project from wgs84 into web mercator
        Polygon newPoly = (Polygon) GeometryEngine.project(polygon, map.getSpatialReference(), webMercator);
        double area = newPoly.calculateArea2D();
       
        //now you have an easier unit of meature to play with
        System.out.println("Area is " + area + webMercator.getUnit().getName() + " squared");
0 Kudos