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

Description

The lengths operation is performed on a geometry service resource. This operation calculates the lengths of each polyline specified in the input array.

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

Parameters

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

Values: html | json
polylines Description: 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 same as the structure of the JSON polyline objects returned by the ArcGIS REST API.

Syntax and Examples:

JSON Structures:

Syntax:

Example:

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

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.

Syntax: polylines={ "url" : "<URL to file>" }
Example: polylines={ "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 polylines. 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.
geodesic Description: If polylines are in geographic coordinate system, then geodesic needs to be set to true in order to calculate the ellipsoidal shortest path distance between each pair of the vertices in the polylines. If lengthUnit is not specificed, then output is always returned in meters.

Example Usage

Example 1: In this example, the length of two input polylines are calculated.

http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/lengths?
sr=4269
&polylines=[%0D%0A+{%0D%0A++%22paths%22+%3A+[%0D%0A+++[[-117%2C34]%2C[-116%2C34]%2C[-117%2C33]]%2C%0D%0A+++[[-115%2C44]%2C[-114%2C43]%2C[-115%2C43]]%0D%0A++]%0D%0A+}%2C%0D%0A+{%0D%0A++%22paths%22+%3A+[%0D%0A+++[[32.49%2C17.83]%2C[31.96%2C17.59]%2C[30.87%2C17.01]%2C[30.11%2C16.86]]%0D%0A++]%0D%0A+}%0D%0A]%0D%0A%0D%0A
&lengthUnit=9036
&geodesic=true
&f=HTML

JSON Response Syntax

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

JSON Response Example

{
"lengths" : [ 456.036465954783, 277.294288451794 ]
}