FRAMES | NO FRAMES Description | Parameters | Examples | Response
Areas and Lengths (Operation)
URL http://<geometryservice-url>/areasAndLengths
Parent Resource Geometry Service

Description

The areasAndLengths operation is performed on a geometry service resource. This operation calculates areas and perimeter lengths for each polygon specified in the input array.

From 10.1 onwards, the input polygon will be simplified when the calculationType is not planar.

You can provide arguments to the areasAndLengths operation as query parameters defined in the parameters table below.

Parent Resource

Geometry Service

Parameters

Parameter Details
f Description: The response format. The default response format is html.

Values: html | json
polygons Description: The array of polygons whose areas and lengths are to be computed. The spatial reference of the polygons is specified by sr. The structure of each polygon in the array is same as the structure of the JSON polygon objects returned by the ArcGIS REST API.

Syntax and Examples:

JSON Structures:

Syntax:

Example:

[
 {
  "rings" : [
   [[-117,34],[-116,34],[-117,33],[-117,34]],
   [[-115,44],[-114,43],[-115,43],[-115,44]]
  ]
 },
 {
  "rings" : [
   [[32.49,17.83],[31.96,17.59],[30.87,17.01],[30.11,16.86],[32.49,17.83]]
  ]
 }
]

URL based:

For a large set of geometries, you can specify a URL to the input geometries stored in a JSON structure in a file on a public server. The expected format of the file’s contents will be exactly the same as that expected if the polygons were directly embedded in the request.

Syntax: polygons={ "url" : "<URL to file>" }
Example: polygons={ "url" : "http://myserver/mygeometries/afile.txt" }

sr Description: The well-known ID of the spatial reference or a spatial reference json object for the input polygons. For a list of valid WKID values, see Projected coordinate Systems and Geographic coordinate Systems.
lengthUnit Description: The length unit in which perimeters of polygons will be calculated. It can be any esriUnits constant. If unit is not specified, the units are derived from sr. For a list of valid units, see esriSRUnitTypeconstants and esriSRUnit2Type Constants.
areaUnit Description: The area unit in which areas of polygons will be calculated. It can be any esriAreaUnits constant. If unit is not specified, the units are derived from sr. For a list of valid units, see esriSRUnitTypeconstants and esriSRUnit2Type Constants.

The list of valid esriAreaUnits constants include, esriSquareInches | esriSquareFeet | esriSquareYards | esriAcres | esriSquareMiles | esriSquareMillimeters | esriSquareCentimeters | esriSquareDecimeters | esriSquareMeters | esriAres | esriHectares | esriSquareKilometers.

JSON Structures: (When using an esriAreaUnits enumeration value)

Syntax:
{
"areaUnit" : "<esriAreaUnits>"
}

Example:

{
"areaUnit" : "esriHectares"
}
calculationType Description: Type defines the area and length calculation for the geometry. The type can be of the following values:

"planar": Planar measurements use 2D Cartesian mathematics to calculate area and length. This type should only be used if the area or length needs to be calculated in the given spatial reference otherwise use "preserveShape".

"geodesic": Use this type if you want to calculate an area or length using only the vertices of the polygon and define the lines between the points as geodesic segments independent of the actual shape of the polygon. A geodesic segment is the shortest path between two points on an ellipsoid.

"preserveShape": This type calculates the area or length of the geometry on the surface of the Earth ellipsoid, for geometry defined in projected or geographic coordinate system. This method preserves the shape of the geometry in its coordinate system. This means the true area or length will be calculated for the geometry you see in the map. (What you see is what you get.)

Example Usage

Example 1: In this example, the area and length of a polygon are calculated. The length is returned in miles and the area in acres.

http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/areasAndLengths?
sr=102009
&polygons=[{"rings" : [[[-628833.344099998,206205.236200001],[-630269.659900002,192298.906100001],[-631848.233800001,173991.394400001],[-616471.690300003,341822.557500001],[-620213.661300004,301450.162799999],[-625923.431999996,237538.0579],[-628833.344099998,206205.236200001]]]}]
&lengthUnit=9035
&areaUnit={"areaUnit" : "esriAcres"}
&type=preserveShape
&f=HTML

JSON Response Syntax

{
"areas" : [ <area1>, <area2> ], "lengths" : [ <length1>, <length2> ]
}

JSON Response Example

{
"areas" : [ 1.0, 0.167199999999997 ],
"lengths" : [ 6.82842712474619, 5.16125300726341 ]
}