Fork me on GitHub

ST_Relate

Signatures

VARCHAR ST_Relate(GEOMETRY geomA, GEOMETRY geomB);
BOOLEAN ST_Relate(GEOMETRY geomA, GEOMETRY geomB, VARCHAR iMatrix);

Description

Returns

  • the DE-9IM intersection matrix for geomA and geomB, or
  • TRUE if geomA and geomB are related by the intersection matrix specified by iMatrix.
This function does not work on GEOMETRYCOLLECTIONs.
Implements the OpenGIS Simple Features Implementation Specification for SQL version 1.2.1.

Examples

SELECT ST_Relate('LINESTRING(1 2, 3 4)',
                 'LINESTRING(5 6, 7 3)');
-- Answer: FF1FF0102

SELECT ST_Relate('POLYGON((1 1, 4 1, 4 5, 1 5, 1 1))',
                 'POLYGON((3 2, 6 2, 6 6, 3 6, 3 2))');
-- Answer: 212101212

SELECT ST_Relate('POLYGON((1 1, 4 1, 4 5, 1 5, 1 1))',
                 'POLYGON((3 2, 6 2, 6 6, 3 6, 3 2))',
                 '212101212');
-- Answer: TRUE

SELECT ST_Relate('POLYGON((1 1, 4 1, 4 5, 1 5, 1 1))',
                 'POLYGON((3 2, 6 2, 6 6, 3 6, 3 2))',
                 '112101212');
-- Answer: FALSE

-- Note: * indicates that all values are accepted.
SELECT ST_Relate('POINT(1 2)', ST_Buffer('POINT(1 2)', 2),
                 '0F*FFF212');
-- Answer: TRUE
See also