Checks whether two geometry objects partially intersect without one lying completely inside the other. Returns true if this condition is met, or false otherwise.
Syntax
boolean ST_Crosses(geometry g1, geometry g2);Parameters
| Parameter | Description |
|---|---|
g1 | The first geometry object. |
g2 | The second geometry object. |
Usage notes
Returns
trueonly when the intersection ofg1andg2is non-empty and has a dimension smaller than the maximum dimension of either object.Returns
trueonly when the intersection is not equal to either input geometry object.Supported DE-9IM (Dimensionally Extended Nine-Intersection Model) matrix patterns:
Pattern Applicable geometry pairs T*T******Point and line, point and area, or line and area T*****T**Line and point, area and point, or area and line 0********Two lines Does not support
GeometryCollectionobjects.Generates a bounding box to enable index usage on the input geometry objects. To skip index usage, use
_ST_Crossesinstead.
Examples
Two lines that partially intersect
SELECT ST_Crosses('LINESTRING(0 0,3 3)'::geometry,'LINESTRING(0 1,1 0)'::geometry);
st_crosses
------------
t
(1 row)Two lines where one contains the other (overlap)
SELECT ST_Crosses('LINESTRING(0 0,3 3)'::geometry,'LINESTRING(0 0,1 1)'::geometry);
st_crosses
------------
f
(1 row)Two lines whose intersection has the same dimension as the inputs
SELECT ST_Crosses('LINESTRING(0 0,3 3)'::geometry,'LINESTRING(1 1,4 4)'::geometry);
st_crosses
------------
f
(1 row)