Relation

Description

NoteNote:

The relation operation was added at 9.3 SP1.

The relation operation is performed on a geometry service resource. This operation determines the pairs of geometries from the input geometry arrays that participate in the specified spatial relation. Both arrays are assumed to be in the spatial reference specified by sr, which is a required parameter. Geometry types cannot be mixed within an array. The relations are evaluated in 2D. In other words, z coordinates are not used.

At 10.1 and later, this operation calls simplify on the input geometries1 and geometries2.

You can provide arguments to the relation operation as query parameters defined in the following parameters table:

Request parameters

Parameter

Details

f

Description:  (Optional) The response format. The default response format is html.
Values:   html | json

geometries1

Description: The first array of geometries used to compute the relations. The structure of each geometry in the array is the same as the structure of the JSON geometry objects returned by the ArcGIS REST API.

JSON structures:

Syntax:

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

All geometries in the geometries1 array should be of the type defined by geometryType.

Example:

{
  "geometryType" : "esriGeometryPoint",
  "geometries" :
  [
    {"x" : -104.5, "y" : 34.74},
    {"x" : -63.53, "y" : 10.23}
  ]
}

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. The expected format of the file’s contents will be exactly the same as that expected if the geometries were directly embedded in the request.

Syntax: geometries1={ "url" : "<URL to file>" }

Example: geometries1={ "url" : "http://myserver/mygeometries/afile1.txt" }

geometries2

Description: The second array of geometries to compute the relations. The structure of each geometry in the array is the same as the structure of the JSON geometry objects returned by the ArcGIS REST API.

JSON structures:

Syntax:

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

All geometries in the geometries2 array should be of the type defined by geometryType.

Example:

{
  "geometryType" : "esriGeometryPolyline",
    "geometries" : 
  [
    {
      "paths" : 
      [
        [[-117,34],[-116,34],[-117,33]],
        [[-115,44],[-114,43],[-115,43]]
      ]
    },
    {
      "paths" : 
      [
        [[32,17],[31,17],[30,17],[30,16]]
      ]
    }
  ]
}

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. The expected format of the file’s contents will be exactly the same as that expected if the geometries were directly embedded in the request.

Syntax: geometries2={ "url" : "<URL to file>" }

Example: geometries2={ "url" : "http://myserver/mygeometries/afile2.txt" }

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.

relation

Description: The spatial relationship to be tested between the two input geometry arrays.

Values: esriGeometryRelationCross | esriGeometryRelationDisjoint | esriGeometryRelationIn | esriGeometryRelationInteriorIntersection | esriGeometryRelationIntersection | esriGeometryRelationLineCoincidence | esriGeometryRelationLineTouch | esriGeometryRelationOverlap | esriGeometryRelationPointTouch | esriGeometryRelationTouch | esriGeometryRelationWithin | esriGeometryRelationRelation

NoteNote:

If the relation is specified as esriGeometryRelationRelation, the relationParam parameter describes the spatial relationship and must be specified.

relationParam

Description: The Shape Comparison Language string to be evaluated. Strings such as RELATE(G1, G2, "FFFTTT***") are accepted, in addition to other kinds of strings.

This string describes the spatial relationship to be tested when the relation parameter is specified as esriGeometryRelationRelation.

For more information, see Shape Comparison Language.

Example usage

Example 1: This example determines which of the two input points lies within the input polygon.

http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer/relation?sr=4326&geometries1={"geometryType":"esriGeometryPoint","geometries":[{"x":-104.53,"y":34.74},{"x":-63.53,"y":10.23}]}&geometries2={"geometryType":"esriGeometryPolygon","geometries":[{"rings":[[[-105,34],[-104,34],[-104,35],[-105,35],[-105,34]]]}]}&relation=esriGeometryRelationWithin&relationParam=&f=html

Example 2: This example uses a Shape Comparison Language string (relationParam) to determine which polygons have intersecting interiors and boundaries.

http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer/relation?sr=4326&geometries1={"geometryType":"esriGeometryPolygon","geometries":[{"rings":[[[0,0],[0,4],[2,2],[3,4],[5,0],[0,0]]]},{"rings":[[[0,4],[3,4],[6.72,3.42],[4.34,2],[0,4]]]}]}&geometries2={"geometryType":"esriGeometryPolygon","geometries":[{"rings":[[[3,4],[6,72,3.42],[4.34,2],[3,4]]]},{"rings":[[[5,1],[7,1],[7,0],[5,0],[5,1]]]},{"rings":[[[1,1],[1,2],[2,1],[1,1]]]},{"rings":[[[3,1],[5,1],[7,1],[7,0],[3,0],[3,1]]]}]}&relation=esriGeometryRelationRelation&relationParam=RELATE(G1,G2,'T***T****')&f=html

JSON response syntax

{
  "relations" : [
    { "geometry1Index" : <geometry1Index1>, "geometry2Index" : <geometry2Index1>},
    { "geometry1Index" : <geometry1Index2>, "geometry2Index" : <geometry2Index2> }
  ]
}

JSON response example

{
 "relations": [
  {
   "geometry1Index": 0,
   "geometry2Index": 3
  },
  {
   "geometry1Index": 1,
   "geometry2Index": 0
  }
 ]
}