Skip To Content

Relation

Description

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. 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

ParameterDetails
geometries1

Specifies 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 API REST de ArcGIS.

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

Syntax:


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

Example:


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

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": "https://myserver/mygeometries/afile1.txt"}
geometries2

Specifies 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 API REST de ArcGIS.

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

Syntax:


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

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]]
      ]
    }
  ]
}

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": "https://myserver/mygeometries/afile2.txt"}
sr

Specifies 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 Using spatial references.

relation

Specifies the spatial relationship to be tested between the two input geometry arrays.

Nota:

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

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

relationParam

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.

f

The response format. The default format is html.

Values: html | json | pjson

Example usage

The following are sample request URLs for relation. This example determines which of the two input points lies within the input polygon.

https://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

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

https://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
    }
  ]
}