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

Description

The difference operation is performed on a geometry service resource. This operation constructs the set-theoretic difference between an array of geometries and another geometry.

You can provide arguments to the difference 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
geometries Description: An array of points, multipoints, polylines or polygons. The structure of each geometry in the array is same as the structure of the json geometry objects returned by the ArcGIS REST API.

Syntax and Examples:

JSON Structures:

Syntax:
{
"geometryType" : "<esriGeometryPoint | esriGeometryMultipoint | esriGeometryPolyline | esriGeometryPolygon >"
"geometries" : [ <geometry1>, <geometry2> ]
}
Example:
{
"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 Description: A single geometry of any type, of dimension equal to or greater than the elements of "geometries". 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 | esriGeometryPolygon | esriGeometryMultipoint>",
"geometry" : <geometry1>
}
Example:
 
{
"geometryType" : "esriGeometryPoint",
"geometry" : { "rings" : [ [[-117,34],[-116,34],[-117,33],[-117,34]], [[-115,44],[-114,43],[-115,43],[-115,44]] ] }
}
sr Description: The well-known ID of the spatial reference or a spatial reference json object for the input geometries. For a list of valid WKID values, see Projected coordinate Systems and Geographic coordinate Systems.

Example Usage

Example 1: Calculate Difference between two polygons

http://sampleserver3.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer/difference?
sr=4269
&geometries={"geometryType" : "esriGeometryPolygon","spatialReference" :{"wkid" : 4269},"geometries" :[{"rings" : [[[-75.48928066099995,39.714858219000064],[-75.4759742679999,39.720084384000074],[-75.47476845699993,39.741832093000085],[-75.46039411899994,39.763362027000085],[-74.73882472699995,40.17772564400008],[-74.9166543419999,39.17063854200006],[-75.01440707699993,39.198363837000045],[-75.11995811199995,39.18469178100008],[-75.4156722749999,39.374971842000036],[-75.55276303999995,39.49051430700007],[-75.5166888839999,39.56656841600005],[-75.57023418699993,39.61773496300009],[-75.48928066099995,39.714858219000064]]]}]}
&geometry={"geometryType" : "esriGeometryPolygon","spatialReference" :{"wkid" : 4269},"geometry" :{"rings" : [[[-75.46039411899994,39.763362027000085],[-74.73882472699995,40.17772564400008],[-75.46039411899994,39.763362027000085]]]}}
&f=html

JSON Response Syntax

{
"geometryType" : "<esriGeometryPoint | esriGeometryMultipoint | esriGeometryPolyline | esriGeometryPolygon >"
"geometries" : [
<geometry1>, <geometry2> ]
}

JSON Response Example

{
  "geometryType" : "esriGeometryPolygon", 
  
  "geometries" : 
  [
    {
      "rings" : 
      [
        [
          [-74.738824727, 40.1777256440001], 
          [-74.916654342, 39.1706385420001], 
          [-75.014407077, 39.198363837], 
          [-75.1199581119999, 39.184691781], 
          [-75.415672275, 39.374971842], 
          [-75.5527630399999, 39.4905143070001], 
          [-75.516688884, 39.5665684160001], 
          [-75.570234187, 39.617734963], 
          [-75.489280661, 39.7148582190001], 
          [-75.475974268, 39.7200843840001], 
          [-75.474768457, 39.741832093], 
          [-75.4603941189999, 39.763362027], 
          [-74.738824727, 40.1777256440001]
        ]
      ]
    }
  ]
}