ST_Relate

ST_Relate takes two geometry columns and a string and returns a boolean column. The function returns True if the first geometry and the second geometry satisfy the spatial relationship defined by the specified DE-9IM string code; otherwise, it returns False. The string code contains nine characters that represent the nine spatial relations of the dimensionally extended 9-intersection model (DE-9IM). The character values indicate the dimensionality of the relationship: 0 for points, 1 for linestrings, 2 for polygons, and 'F' to indicate an empty set.

FunctionSyntax
Pythonrelate(geometry1, geometry2, relation)
SQLST_Relate(geometry1, geometry2, relation)
Scalarelate(geometry1, geometry2, relation)

For more details, go to the GeoAnalytics Engine API reference for relate.

This function implements the OpenGIS Simple Features Implementation Specification for SQL 1.2.1.

Examples

PythonPythonSQLScala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
from geoanalytics.sql import functions as ST, Linestring, Polygon

data = [
    (Linestring([[[10,10],[30,30]]]), Linestring([[[20,20],[40,40]]])),
    (Linestring([[[10,10],[30,30]]]), Linestring([[[10,10],[30,30]]])),
]

df = spark.createDataFrame(data, ["linestring1", "linestring2"])

df.select(ST.relate("linestring1", "linestring2", relation="1FFF0FFF2").alias("relate")).show()
Result
Use dark colors for code blocksCopy
1
2
3
4
5
6
+------+
|relate|
+------+
| false|
|  true|
+------+

Version table

ReleaseNotes

1.0.0

Python and SQL functions introduced

1.5.0

Scala function introduced

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