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

Description

The distance operation is performed on a geometry service resource. It reports the planar (projected space) / geodesic shortest distance between A and B. sr is a projected coordinate system. Distance is reported in the linear units specified by units or the units of sr if units is null.

You can provide arguments to the distance 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
geometry1 Description: The geometry from where the distance is to be measured. The structure of geometry is same as the structure of the JSON geometry objects returned by the ArcGIS REST API. The use of simple syntax is not supported.

Syntax and Examples:

JSON Structures:

Syntax:
{
"geometryType" : "<esriGeometryPoint | esriGeometryPolyline | esriGeometryEnvelope | esriGeometryPolygon | esriGeometryMultipoint>",
"geometry" : <geometry1>
}
Example:
{
 "geometryType" : "esriGeometryPoint",
 "geometry" : {
     "x" : -118.15, "y" : 33.80, "spatialReference" : {"wkid" : 4326}
  }
}
        
geometry2 Description: The geometry to which the distance is to be measured. The structure of geometry is same as the structure of the JSON geometry objects returned by the ArcGIS REST API. The use of simple syntax is not supported.

Syntax and Examples:

JSON Structures:

Syntax:
{
"geometryType" : "<esriGeometryPoint | esriGeometryPolyline | esriGeometryEnvelope | esriGeometryPolygon | esriGeometryMultipoint>",
"geometry" : <geometry1>
}
Example:
{
 "geometryType" : "esriGeometryPoint",
 "geometry" : {
    "x" : -118.15, "y" : 33.80, "spatialReference" : {"wkid" : 4326}
  }
}
        
sr Description: The well-known ID or a spatial reference json object for input geometries. If the planar distance is being measured sr can be PCS, and if the geodesic distance is being measured sr can be either PCS or GCS. For a list of valid WKID values, see Projected coordinate Systems and Geographic coordinate Systems.
distanceUnit Description : Specifies the units for measuring distance between the geometry1 and geometry2 geometries. If unit is not specified, the units are derived from sr. For a list of valid units, see esriSRUnitType constants and esriSRUnit2Type constants.
geodesic Description : If true then measures the geodesic distance between the geometries geometry1 and geometry2. This option when not specified is treated as false.

Example Usage

Example 1: In this example, the distance in miles is computed between two points.

http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/distance?f=html
&sr=4326
&geodesic=true
&distanceUnit=9035
&geometry1={"geometryType":"esriGeometryPoint","geometry":{"x":-117.47697998046874,"y":34.121858211839566,"spatialReference":{"wkid":4326}}}
&geometry2={"geometryType":"esriGeometryPoint","geometry":{"x":-117.41586853027343,"y":34.108125301683316,"spatialReference":{"wkid":4326}}}

JSON Response Syntax

{
"distance" : <distance>
}

JSON Response Example

{
 "distance" : 10
}