Skip to main content
The first variant of the function computes and returns the Dimensionally Extended 9-Intersection Model (DE-9IM) matrix string representing the spatial relationship between the two input geometry objects. The second variant of the function evaluates whether the two input geometries satisfy a specific spatial relationship defined by the provided intersectionMatrix pattern. ST_Relate with intersectionMatrix pattern returning true ST_Relate with intersectionMatrix pattern returning false
It is important to note that this function is not optimized for use in spatial join operations. Certain DE-9IM relationships can hold true for geometries that do not intersect or are disjoint. As a result, it is recommended to utilize other dedicated spatial functions specifically optimized for spatial join processing.

Signatures

ST_Relate(geom1: Geometry, geom2: Geometry)
ST_Relate(geom1: Geometry, geom2: Geometry, intersectionMatrix: String)

Parameters

geom1
Geometry
required
The geom1 value.
geom2
Geometry
required
The geom2 value.
intersectionMatrix
String
The intersection matrix value.

Return type

A string representation.

Examples

SELECT ST_Relate(
        ST_GeomFromWKT('LINESTRING (1 1, 5 5)'),
        ST_GeomFromWKT('POLYGON ((3 3, 3 7, 7 7, 7 3, 3 3))')
)
1010F0212
SELECT ST_Relate(
        ST_GeomFromWKT('LINESTRING (1 1, 5 5)'),
        ST_GeomFromWKT('POLYGON ((3 3, 3 7, 7 7, 7 3, 3 3))'),
       "1010F0212"
)
true