Difference

URL:
https://<root>/Utilities/Geometry/GeometryServer/difference
Methods:
GET
Version Introduced:
10.0

Description

The difference operation is performed on a geometry service resource. This operation constructs the set-theoretic difference between each element of an array of geometries and another geometry, the so-called difference geometry. In other words, let B be the difference geometry. For each geometry, A, in the input geometry array, it constructs A - B. This operation calls simplify on the input geometries and geometry values. You can provide arguments to the difference operation as query parameters defined in the following parameters table.

Request parameters

ParameterDetails

geometries

Specifies an array of points, multipoints, polylines, or polygons. The structure of each geometry in the array is the same as the structure of the JSON geometry objects returned by ArcGIS REST API.

Syntax

Use dark colors for code blocksCopy
1
{"geometryType": "<esriGeometryPoint | esriGeometryMultipoint | esriGeometryPolyline | esriGeometryPolygon >","geometries" : [ <geometry1>, <geometry2> ]}

Example

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
  "geometryType": "esriGeometryPolyline",
  "geometries": [
    {
      "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]]
      ]
    }
  ]
}

geometry

Specifies a single geometry of any type and of a dimension equal to or greater than the geometries elements. 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

Use dark colors for code blocksCopy
1
{"geometryType": "<esriGeometryPoint | esriGeometryPolyline | esriGeometryPolygon | esriGeometryMultipoint>","geometry": <geometry1> }

Example

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
{
  "geometryType": "esriGeometryPolygon",
  "geometry": {
    "rings": [
      [[-117,34],[-116,34],[-117,33],[-117,34]],
      [[-115,44],[-114,43],[-115,43],[-115,44]]
    ]
  }
}

sr

Specifies the well-known ID (WKID) of the spatial reference or a spatial reference JSON object for the input geometries values. For a list of valid WKID values, see Using spatial references.

f

The response format. The default response format is html.

Values: html | json | pjson

Example usage

The following is a sample request URL for difference that constructs the difference between polygons:

Use dark colors for code blocksCopy
1
https://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer/difference?sr=4269&geometries={"geometryType":"esriGeometryPolygon","geometries":[{"rings":[[[-75.5,39.7],[-74.7,40.2],[-74.9,39.2],[-75.1,39.1],[-75.5,39.7]]]},{"rings":[[[-75,39.8],[-74,40],[-74.5,39],[-75,39.8]]]}]}&geometry={"geometryType":"esriGeometryPolygon","geometry":{"rings":[[[-75,39.8],[-74,40],[-74.5,39],[-75,39.8]]]}}&f=pjson

JSON Response syntax

Use dark colors for code blocksCopy
1
2
3
4
{
  "geometryType": "<esriGeometryPoint | esriGeometryMultipoint | esriGeometryPolyline | esriGeometryPolygon >",
  "geometries": [<geometry1>, <geometry2>]
}

JSON Response example

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{
  "geometryType": "esriGeometryPolygon",
  "geometries": [
    {
      "rings": [
        [
          [
            -74.899999999999977,
            39.200000000000045
          ],
          [
            -75.099999999999966,
            39.10000000000008
          ],
          [
            -75.499999999999943,
            39.700000000000045
          ],
          [
            -74.699999999999989,
            40.200000000000045
          ],
          [
            -74.770833332999985,
            39.84583333300003
          ],
          [
            -74.999999999999943,
            39.800000000000068
          ],
          [
            -74.833333332999985,
            39.53333333300003
          ],
          [
            -74.899999999999977,
            39.200000000000045
          ]
        ]
      ]
    },
    {
      "rings": []
    }
  ]
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.