Skip to main content

ST_Crosses

Tests whether two geometries cross each other - their interiors intersect but neither contains the other.

Syntax​

ST_Crosses(geometry_a, geometry_b)

Parameters​

ParameterTypeDescription
geometry_aGeometryFirst geometry
geometry_bGeometrySecond geometry

Returns​

TypeDescription
BooleanTrue if geometries cross, false otherwise

Examples​

Line Crossing Polygon​

SELECT ST_Crosses(
ST_GeomFromText('LINESTRING(0 0, 4 4)'),
ST_GeomFromText('POLYGON((1 0, 3 0, 3 2, 1 2, 1 0))')
);
-- Returns: true

Intersecting Lines​

SELECT ST_Crosses(
ST_GeomFromText('LINESTRING(0 0, 4 4)'),
ST_GeomFromText('LINESTRING(0 4, 4 0)')
);
-- Returns: true (lines cross at (2,2))

Find Road-River Intersections​

SELECT r.name as road, v.name as river
FROM roads r, rivers v
WHERE ST_Crosses(r.geom, v.geom);

Notes​

  • Applies to line/line, line/polygon, and multipoint/line combinations
  • For lines: they must intersect at an interior point (not just endpoints)
  • For line/polygon: line must enter and exit the polygon
  • Does not apply to polygon/polygon (use ST_Overlaps instead)

See Also​