ST_Crosses
Signature
BOOLEAN ST_Crosses(GEOMETRY geomA, GEOMETRY geomB);
Description
Returns TRUE if geomA crosses geomB.
Crosses means that:
The intersection between
geomAandgeomBgives a new Geometry whose dimension is less than the maximum dimension of the input Geometries.geomAandgeomBhave some, but not all interior points in common.The intersection set is interior to both
geomAandgeomB.
Note
Implements the OpenGIS Simple Features Implementation Specification for SQL version 1.2.1
Warning
This predicate does not yet support spatial indices, but it will in a future release. Use it in conjunction with && operator. See here for more details.
Note
In the OpenGIS Simple Features Specification this predicate is only defined for (POINT, LINESTRING), (POINT, POLYGON), (LINESTRING, LINESTRING), and (LINESTRING, POLYGON) situations.
JTS and Geos extend this definition to (POLYGON, LINESTRING), (POLYGON, POINT) and (LINESTRING, POINT) situations.
Examples
Cases where ST_Crosses is true
SELECT ST_Crosses(geomA, geomB) FROM input_table;
-- Answer: TRUE
geomA MULTIPOINT |
geomB LINESTRING |
|---|---|
MULTIPOINT((1 3), (4 1), (4 3)) |
LINESTRING(1 1, 5 2, 2 5) |

geomA MULTIPOINT |
geomB POLYGON |
|---|---|
MULTIPOINT((1 3), (4 1), (4 3)) |
POLYGON((2 2, 5 2, 5 5, 2 5, 2 2)) |

geomA LINESTRING |
geomB LINESTRING |
|---|---|
LINESTRING(1 3, 5 3) |
LINESTRING(1 1, 5 2, 2 5) |

geomA LINESTRING |
geomB POLYGON |
|---|---|
LINESTRING(1 3, 5 3) |
POLYGON((2 2, 5 2, 5 5, 2 5, 2 2)) |

geomA POLYGON |
geomB LINESTRING |
|---|---|
POLYGON((1 1, 4 1, 4 4, 1 4, 1 1)) |
LINESTRING(1 5, 5 1) |

geomA POLYGON |
geomB MULTIPOINT |
|---|---|
POLYGON((1 1, 4 1, 4 4, 1 4, 1 1)) |
MULTIPOINT((2 3), (4 5), (5 1)) |

geomA LINESTRING |
geomB MULTIPOINT |
|---|---|
LINESTRING(2 1, 1 3, 3 4) |
MULTIPOINT((1 3), (4 1), (4 3)) |

Cases where ST_Crosses is false
SELECT ST_Crosses(geomA, geomB) FROM input_table;
-- Answer: FALSE
geomA POLYGON |
geomB POLYGON |
|---|---|
POLYGON((1 1, 4 1, 4 4, 1 4, 1 1)) |
POLYGON((2 2, 5 2, 5 5, 2 5, 2 2)) |

geomA POLYGON |
geomB POLYGON |
|---|---|
LINESTRING(1 1, 5 2, 2 5) |
LINESTRING(3 4, 5 2) |
