Lengths
- URL:https://<geometryservice-url>/lengths
- Version Introduced:9.3
Description
The lengths operation is performed on a geometry service resource. This operation calculates the 2D Euclidean or geodesic lengths of each polyline specified in the input array.
You can provide arguments to the lengths operation as query parameters defined in the following parameters table:
Request parameters
Parameter |
Details |
---|---|
f |
The response format. The default response format is html. Values: html | json |
polylines |
The array of polylines whose lengths are to be computed. The spatial reference of the polylines is specified by sr. The structure of each polyline in the array is the same as the structure of the JSON polyline 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 polylines were directly embedded in the request. Syntax: polylines={ "url" : "<URL to file>" } Example: polylines={ "url" : "http://myserver/mygeometries/afile.txt" } |
sr |
The well-known ID (WKID) of the spatial reference or a spatial reference JSON object for the input polylines. For a list of valid WKID values, see Projected coordinate systems and Geographic coordinate systems. |
lengthUnit |
The unit in which lengths of polylines will be calculated. If calculationType is planar, lengthUnit can be any esriUnits constant. If calculationType is planar and lengthUnit is not specified, the units are derived from sr. If calculationType is not planar, lengthUnit must be a linear esriUnits constant such as esriSRUnit_Meter or esriSRUnit_SurveyMile. If calculationType is not planar and lengthUnit is not specified, the units are meters. For a list of valid units, see esriSRUnitType Constants and esriSRUnit2Type Constants. |
geodesic |
Deprecated at 10.1. Use the calculationType parameter instead. If polylines are in a geographic coordinate system, geodesic needs to be set to true to calculate the ellipsoidal shortest-path distance between each pair of the vertices in the polylines. If lengthUnit is not specified, the output is always returned in meters. |
calculationType |
calculationType defines the length calculation for the geometry. The type can be one of the following values:
|
Example usage
In this example, the lengths of two input polylines are calculated. The preserveShape calculation type is used. The result is given in kilometers.
JSON Response syntax
{
"lengths" : [ <length1>, <length2>, ..., <lengthN> ]
}
JSON Response example
{
"lengths": [
456.04101753137257,
277.29464412330174
]
}