- URL:
- https://<root>/Utilities/Geometry/GeometryServer/distance
- Methods:
GET- Version Introduced:
- 10.0
Description
The distance operation is performed on a geometry service resource. It reports the 2D Euclidean or geodesic distance between the two geometries. This operation calls simplify on the input geometry1 and geometry2 values when the geodesic parameter is true. You can provide arguments to the distance operation as query parameters defined in the following parameters table.
Request parameters
| Parameter | Details |
|---|---|
| Specifies the geometry from which the distance is measured. The structure of the geometry is the same as the structure of the JSON geometry objects returned by ArcGIS REST API. The use of simple syntax is not supported. Syntax Example |
| Specifies the geometry to which the distance is measured. The structure of the geometry is the same as the structure of the JSON geometry objects returned by ArcGIS REST API. The use of simple syntax is not supported. Syntax Example |
| Specifies the well-known ID (WKID) or a spatial reference JSON object for input geometries. The spatial reference can be either a projected coordinate system (PCS) or a geographic coordinate system (GCS). For a list of valid WKID values, see Using spatial references. |
(Optional) | Specifies the units for measuring distance between the For planar distance, if For geodesic distance, If |
(Optional) | If Values: |
| The response format. The default response format is Values: |
Example usage
The following is a sample request URL for distance that demonstrates how the geodesic distance in meters is computed between a polygon and a point:
https://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer/distance?sr=4326&geometry1={"geometryType":"esriGeometryPolygon","geometry":{"rings":[[[-117,34],[-117,35],[-116,35],[-116,34],[-117,34]]]}}&geometry2={"geometryType":"esriGeometryPoint","geometry":{"x":-115,"y":36}}&geodesic=true&f=pjsonJSON Response syntax
{"distance": <distance>}JSON Response example
{"distance": 143321.57818195896}