Areas and Lengths
- URL:https://<geometryservice-url>/areasAndLengths
- Version Introduced:9.3
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. At 10.1 and later, the input polygon is simplified when the calculationType is not planar. You can provide arguments to the areasAndLengths operation as query parameters defined in the following parameters table.
Request parameters
Parameter |
Details |
---|---|
polygons |
Specifies 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 the same as the structure of the JSON polygon objects returned by ArcGIS REST API. JSON structures: Syntax:
Example:
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 the same as that expected if the polygons were directly embedded in the request. URL-based syntax
URL-based example
|
sr |
Specifies the well-known ID (WKID) of the spatial reference or a spatial reference JSON object for the input polygons. For a list of valid WKID values, see Using spatial references. |
lengthUnit |
Specifies the length unit used to calculate the perimeters of the polygons. The lengthUnit must be an integer representing the well-known id (WKID) of an esriUnits constant. If calculationType is planar,, lengthUnit can be any WKID of an esriUnits constant. If lengthUnit is not specified, the units are derived from sr. If calculationType is not planar, , lengthUnit must be a WKID of a linear esriUnits constant, such as esriSRUnit_Meter or esriSRUnit_SurveyMile. If lengthUnit is not specified, the units are meters. For a list of valid units, see esriSRUnitType Constants and esriSRUnit2Type Constant. |
areaUnit |
Specifies the area unit used to calculate the areas of the polygons. The areaUnit can be an integer representing the well-known id (WKID) of an esriUnits constant or an esriUnits constant directly in the form shown below. If calculationType is planar, areaUnit can be any esriUnits constant. If areaUnit is not specified, the units are derived from sr. If calculationType is not planar, areaUnit must be a linear esriUnits constant such as esriSRUnit_Meter or esriSRUnit_SurveyMile. If areaUnit is not specified, the units are meters. For a list of valid units, see esriSRUnitType Constants and esriSRUnit2Type Constant. Additional Values for areaUnit: esriSquareInches | esriSquareFeet | esriSquareYards | esriAcres | esriSquareMiles | esriSquareMillimeters | esriSquareCentimeters | esriSquareDecimeters | esriSquareMeters | esriAres | esriHectares | esriSquareKilometers Syntax
Example
|
calculationType |
Specifies the type defined for the area and length calculation of the input geometries. The type can be one of the following values:
|
f |
The response format. The default response format is html. Values: html | json | pjson |
Example usage
The following is a sample request URL for areasAndLengths demonstrating how the areas and lengths of two polygons are calculated. The lengths are returned in miles, and the areas are returned in acres:
https://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer/areasAndLengths?sr=102009&polygons=[%7B%22rings%22:[[[-628833,206205],[-630269,192298],[-631848,173991],[-616471,341822],[-620213,301450],[-625923,237538],[-628833,206205]]]%7D,%7B%22rings%22:[[[0,0],[0,100000],[100000,100000],[100000,0],[0,0]]]%7D]&lengthUnit=9035&areaUnit=%7B%22areaUnit%22:%22esriAcres%22%7D&calculationType=preserveShape&f=html
JSON Response syntax
{
"areas": [ <area1>, <area2>, ..., <areaN> ],
"lengths": [ <length1>, <length2>, ..., <lengthN> ]
}
JSON Response example
{
"areas": [
2150.340979272913,
2800449.740201426
],
"lengths": [
222.93213167603818,
264.5927746444603
]
}