Name

ST_Crosses — Tests if a Geometry A crosses a Geometry B, returns True if so.

Synopsis

boolean ST_Crosses(bytea GeomA, bytea GeomB);

Alias

Crosses

Description

Returns true if Geometry A crosses a Geometry B.

The crosses predicate has the following equivalent definitions:

  • The geometries have some but not all interior points in common.

  • In mathematical terms:

    Equation 9.0. 

    a.Crosses(b) «-» (dim(I(a) ∩ I(b)) < max(dim(I(a)), dim(I(b)))) Ʌ (a ∩ b ≠a ) Ʌ (a ∩ b ≠b)

  • The DE-9IM Intersection Matrix for the two geometries is:

    • T*T****** (for P/L, P/A, and L/A situations)

    • T*****T** (for L/P, L/A, and A/L situations)

    • 0******** (for L/L situations)

    For any other combination of dimensions this predicate returns false.

    The SFS defined this predicate only for P/L, P/A, L/L, and L/A situations. JTS extends the definition to apply to L/P, A/P and A/L situations as well. This makes the relation symmetric.

[Note]

The term P is used to refer to 0 dimensional geometries (Points and MultiPoints), L is used to refer to one-dimensional geometries (LineStrings and MultiLineStrings) and A is used to refer to two-dimensional geometries (Polygons and MultiPolygons).

Coordinate Dimensions
2D3DM
Spatial Standards Support
OGC SFS for SQL. 1.1 (1999)OGC SFS for SQL. 1.1.0 (2005)OGC SFS for SQL. 1.2.0 (2006)SQL-MM Part 3
2.1.1.2 , 2.1.13.37.2.19.17.2.8.15.1.29

Examples

--P/L
SELECT ST_Crosses(MPoint,Line) as CrossesPL,ST_Crosses(Line,MPoint) as CrossesLP,ST_Relate(MPoint,Line) from 
(SELECT ST_GeomFromText('LINESTRING (10 15, 10 27, 20 20, 25 30)') as Line, 
 ST_GeomFromText('MULTIPOINT (10 30, 15 20, 10 20, 20 25, 17 23)') as MPoint) as foo;

  crossespl | crosseslp | st_relate
-----------+-----------+-----------
 t         | t         | 0F0FFF102

--P/A
SELECT ST_Crosses(MPoint,Poly) as CrossesPA,ST_Crosses(Poly,MPoint) as CrossesAP,ST_Relate(MPoint,Poly) from 
(SELECT ST_GeomFromText('POLYGON ((10 30, 5 10, 30 20, 30 30, 20 40, 10 30))') as Poly, 
 ST_GeomFromText('MULTIPOINT (5 30, 15 20)') as MPoint) as foo;

 crossespa | crossesap | st_relate
-----------+-----------+-----------
 t         | t         | 0F0FFF212

--L/A
SELECT ST_Crosses(Line,Poly) as CrossesLA,ST_Crosses(Poly,Line) as CrossesAL,ST_Relate(Line,Poly) from 
(SELECT ST_GeomFromText('POLYGON ((10 30, 5 10, 30 20, 30 30, 20 40, 10 30))') as Poly, 
 ST_GeomFromText('LINESTRING (0 20, 15 25, 20 30, 35 25, 35 25)') as Line) as foo;

 crossesla | crossesal | st_relate
-----------+-----------+-----------
 t         | t         | 101FF0212

--L/L
SELECT ST_Crosses(LA,LB) as CrossesLL,ST_Crosses(LB,LA) as CrossesLL2,ST_Relate(LA,LB) 
from (SELECT ST_GeomFromText('LINESTRING (0 20, 15 25, 20 30, 35 25)') as LA, 
 ST_GeomFromText('LINESTRING (10 35, 5 25, 15 20, 15 10)') as LB) as foo;
 crossesll | crossesll2 | st_relate
-----------+------------+-----------
 t         | t          | 0F1FF0102
P/L
P/A
L/A
L/L

Related functions

ST_Crosses, ST_Relate