Areas and Lengths
- URL:http:// <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 |
---|---|
f |
Description: (Optional) 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 the same as the structure of the JSON polygon objects returned by the ArcGIS REST API. JSON structures: Syntax:
Example:
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 the perimeters of polygons will be calculated. If calculationType is planar, then lengthUnit can be any esriUnits constant. If lengthUnit is not specified, the units are derived from sr. If calculationType is not planar, then lengthUnit must be 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 |
Description: The area unit in which areas of polygons will be calculated. If calculationType is planar, then areaUnit can be any esriUnits constant. If areaUnit is not specified, the units are derived from sr. If calculationType is not planar, then areaUnit must be a linear esriUnits constant such as esriSRUnit_Meter or esriSRUnit_SurveyMile. If areaUnit is not specified, then the units are meters. For a list of valid units, see esriSRUnitType Constants and esriSRUnit2Type Constant. 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:
Example:
|
calculationType |
Description: The type defined for the area and length calculation of the input geometries. The type can be one of the following values:
|
Example usage
In this example, the areas and lengths of two polygons are calculated. The lengths are returned in miles, and the areas are returned in acres.
JSON response syntax
{
"areas" : [ <area1>, <area2>, ..., <areaN> ],
"lengths" : [ <length1>, <length2>, ..., <lengthN> ]
}
JSON response example
{
"areas":
[
2150.340979272913,
2800449.740201426
],
"lengths":
[
222.93213167603818,
264.5927746444603
]
}