Geometry service GetAreasAndLengths method

The GetAreasAndLengths method calculates area and perimeter for each polygon in the input array.

GetAreasAndLengths(SpatialReference SpatialReference, Polygon[] InPolygonArray, out double[] Lengths)




The SpatialReference of the geometries in the InPolygonArray parameter. Cannot be null.


The array of Polygons on which area and boundary length will be calculated (on each Polygon). All geometries are assumed to be in the coordinate system defined by SpatialReference.


A double[] containing the boundary length (perimeter) for each polygon in the input array. The variable is populated when the method is called.

Return Value

A double[] containing the area for each polygon in the input array, InPolygonArray.


The area and perimeter values are computed in the units of the input spatial reference. It is not recommended that this method be used on geometries having latitude-longitude coordinates, since the length would then be calculated in units of "degrees" and the area would be calculated in units of "square degrees". Use the GetAreasAndLengthsGeodesic, the GetAreasAndLengthsPreserveShape, or the GetLengthsGeodesic method to compute areas and lengths for geometries with latitude-longitude coordinates.



Geometry_GeometryServer geometryService = new Geometry_GeometryServer();

geometryService.Url = "http://localhost:6080/arcgis/services/Geometry/GeometryServer";


SpatialReference inputSpatialReference = geometryService.FindSRByWKID("EPSG", 54004, -1, true, true);


// New PointN array

PointN pnt1 = new PointN();

pnt1.X = 100000;

pnt1.Y = 300000;

PointN pnt2 = new PointN();

pnt2.X = 100000;

pnt2.Y = 350000;

PointN pnt3 = new PointN();

pnt3.X = 900000;

pnt3.Y = 350000;

PointN[] pnts1 = new PointN[] { pnt1, pnt2, pnt3};


// New PolylineN

Path path1 = new Path();

path1.PointArray = pnts1;

Path[] paths = new Path[] { path1 };

PolylineN polylinen = new PolylineN();

polylinen.PathArray = paths;


// New PolygonN

Ring ring1 = new Ring();

ring1.PointArray = pnts1;

Ring[] rings = new Ring[] { ring1 }; class=codesample>PolygonN polygonn = new PolygonN();

polygonn.RingArray = rings;

PolygonN[] polygonArray = new PolygonN[] { polygonn };


double[] lengths = null;

double[] areas = geometryService.GetAreasAndLengths(inputSpatialReference, polygonArray, out lengths);


Dim geomeTryService As Geometry_GeometryServer = New Geometry_GeometryServer()

geomeTryService.Url = "http://localhost:6080/arcgis/services/Geometry/GeometryServer"


Dim inputSpatialReference As SpatialReference = geomeTryService.FindSRByWKID("EPSG", 54004, -1, True, True)

' New PointN array

Dim pnt1 As PointN = New PointN()

pnt1.X = 100000

pnt1.Y = 300000


Dim pnt2 As PointN = New PointN()

pnt2.X = 100000

pnt2.Y = 350000


Dim pnt3 As PointN = New PointN()

pnt3.X = 900000

pnt3.Y = 350000


Dim pnts1() As PointN = New PointN() {pnt1, pnt2, pnt3}


' New PolylineN

Dim path1 As Path = New Path()

path1.PointArray = pnts1


Dim paths() As Path = New Path() {path1}


Dim polylinen As PolylineN = New PolylineN()

polylinen.PathArray = paths


' New PolygonN

Dim ring1 As Ring = New Ring()

ring1.PointArray = pnts1

Dim rings() As Ring = New Ring() {ring1}


Dim polygonn As PolygonN = New PolygonN()

polygonn.RingArray = rings

Dim polygonArray() As PolygonN = New PolygonN() {polygonn}


Dim lengths() As Double = Nothing

Dim areas As Double() = geomeTryService.GetAreasAndLengths(inputSpatialReference, polygonArray, lengths)


String serviceURL = "http://localhost:6080/arcgis/services/Geometry/GeometryServer";

GeometryServerBindingStub geometryService = new GeometryServerBindingStub(serviceURL);


//Test GetAreasAndLength

SpatialReference inputSpatialReference = geometryService.findSRByWKID(

      "EPSG", 54004, -1, true, true);


      //New PointN array

PointN pnt1 = new PointN();




PointN pnt2 = new PointN();




PointN pnt3 = new PointN();




PointN[] points1 = new PointN[] { pnt1, pnt2, pnt3 };


//New PolylineN

Path path1 = new Path();



Path[] paths1 = new Path[] { path1 };


PolylineN polylinen = new PolylineN();



//New PolygonN

Ring ring1 = new Ring();



Ring[] rings1 = new Ring[] { ring1 };


PolygonN polygonN1 = new PolygonN();



PolygonN[] polygonArray1 = new PolygonN[] { polygonN1 };


//Get areas and length

Holder<double[]> lengthsArray = new Holder<double[]>();

Holder<double[]> areasArray = new Holder<double[]>();


geometryService.getAreasAndLengths(inputSpatialReference, polygonArray1,

      lengthsArray, areasArray);