All Products
Search
Document Center

PolarDB:ST_Crosses

Last Updated:Mar 28, 2026

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

ParameterDescription
g1The first geometry object.
g2The second geometry object.

Usage notes

  • Returns true only when the intersection of g1 and g2 is non-empty and has a dimension smaller than the maximum dimension of either object.

  • Returns true only when the intersection is not equal to either input geometry object.

  • Supported DE-9IM (Dimensionally Extended Nine-Intersection Model) matrix patterns:

    PatternApplicable 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 GeometryCollection objects.

  • Generates a bounding box to enable index usage on the input geometry objects. To skip index usage, use _ST_Crosses instead.

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)