Functions / PostGIS / ST_Crosses
PostGISSpatial Relationships

ST_Crosses

What is ST_Crosses?

ST_Crosses is a PostGIS spatial predicate that returns true when two geometries share some interior points but not all, and the dimension of their intersection is less than the maximum dimension of either input. In practical terms: a line crossing a polygon, or two lines crossing at a point.

SQL
ST_Crosses(geometry geomA, geometry geomB)boolean

Valid pairs are (Point/Line, Point/Polygon, Line/Line, Line/Polygon) — "crossing" is only meaningful for geometries that slice through each other.

When would you use ST_Crosses?

Use ST_Crosses to find linear features that pierce polygonal features — roads crossing watersheds, pipelines crossing property parcels, or rivers crossing country borders. It is also the right predicate for detecting intersections between two line networks where you specifically want true crossings and not shared segments.

SQL
1SELECT r.id, w.name
2FROM roads r
3JOIN watersheds w ON ST_Crosses(r.geom, w.geom);

FAQs

How is ST_Crosses different from ST_Intersects?

ST_Intersects returns true whenever two geometries share any point at all — including when one is contained inside the other, or when they only touch at their boundaries. ST_Crosses is stricter: the geometries must share some interior but not all of one, and the intersection must be of lower dimension than the higher-dimension input.

Does ST_Crosses work for two polygons?

No — two polygons can never "cross" in the OGC sense. Their intersection is either empty, a point, a line, or another polygon, which doesn't fit the cross predicate's requirement that the intersection have lower dimension than at least one input. Use ST_Overlaps for polygon-polygon partial overlap instead.

What DE-9IM pattern does it match?

For point/line and point/polygon it is T*T******; for line/line it is 0******** (intersection is a point, i.e. dimension 0); for line/polygon it is T*T******. The pattern depends on the input types because the predicate is only meaningful for specific combinations.

Is ST_Crosses index-accelerated?

Yes. PostGIS applies a bounding-box overlap filter via GiST indexes before running the exact predicate, which makes ST_Crosses efficient in joins against large line or polygon layers.