ST_Crosses — Returns true if two geometries have some, but not all, interior points in common.
boolean ST_Crosses(geometry g1, geometry g2
ST_Crosses takes two geometry objects and
true if their intersection "spatially cross", that is, the
geometries have some, but not all interior points in common. The
intersection of the interiors of the geometries must not be the empty
set and must have a dimensionality less than the maximum dimension
of the two input geometries. Additionally, the intersection of the two
geometries must not equal either of the source geometries. Otherwise, it
In mathematical terms, this is expressed as:
The DE-9IM Intersection Matrix for the two geometries is:
T*T****** (for Point/Line, Point/Area, and Line/Area situations)
T*****T** (for Line/Point, Area/Point, and Area/Line situations)
0******** (for Line/Line situations)
For any other combination of dimensions this predicate returns false.
The OpenGIS Simple Features Specification defines this predicate only for Point/Line, Point/Area, Line/Line, and Line/Area situations. JTS / GEOS extends the definition to apply to Line/Point, Area/Point and Area/Line situations as well. This makes the relation symmetric.
This function automatically includes a bounding box comparison that makes use of any spatial indexes that are available on the geometries.
Enhanced: 3.0.0 enabled support for
This method implements the OGC Simple Features Implementation Specification for SQL 1.1. s126.96.36.199
This method implements the SQL/MM specification. SQL-MM 3: 5.1.29
The following illustrations all return
Consider a situation where a user has two tables: a table of roads and a table of highways.
CREATE TABLE roads ( id serial NOT NULL, geom geometry, CONSTRAINT roads_pkey PRIMARY KEY (road_id) );
CREATE TABLE highways ( id serial NOT NULL, the_gem geometry, CONSTRAINT roads_pkey PRIMARY KEY (road_id) );
To determine a list of roads that cross a highway, use a query similiar to:
SELECT roads.id FROM roads, highways WHERE ST_Crosses(roads.geom, highways.geom);