Skip to content
Apache Sedona 1.9.0 is out now, featuring Spark 4.1 support, proj4sedona CRS transformation, Bing Tile functions, and more!

ST_Intersects

Introduction: Return true if A intersects B. Polymorphic over input type:

  • (Geometry, Geometry) — topological intersection via JTS.
  • (Geography, Geography) — topological intersection via S2.
  • (Box2D, Box2D) — closed-interval bbox intersection on both axes. Matches PostGIS && on box2d. Edge- and corner-touching boxes count as intersecting. Throws IllegalArgumentException on inverted bounds.
  • (Box3D, Box3D) — closed-interval bbox intersection on all three axes. Matches PostGIS &&& on box3d. Edge-, face-, and corner-touching boxes count as intersecting. Throws on inverted bounds on any axis.

ST_Intersects returning true ST_Intersects returning false

Format:

  • ST_Intersects(A: Geometry, B: Geometry)
  • ST_Intersects(A: Geography, B: Geography)
  • ST_Intersects(A: Box2D, B: Box2D) (Since v1.9.1)
  • ST_Intersects(A: Box3D, B: Box3D) (Since v1.9.1)

Return type: Boolean

Since: v1.0.0

SQL Example

SELECT ST_Intersects(ST_GeomFromWKT('LINESTRING(-43.23456 72.4567,-43.23456 72.4568)'), ST_GeomFromWKT('POINT(-43.23456 72.4567772)'))

Output:

true

Box2D example:

SELECT ST_Intersects(
    ST_MakeBox2D(ST_Point(0.0, 0.0), ST_Point(10.0, 10.0)),
    ST_MakeBox2D(ST_Point(5.0, 5.0), ST_Point(15.0, 15.0)))

Output:

true

Box2D optimization

ST_Intersects(box_col, lit_box) over a Box2D column and a literal Box2D is recognised by Sedona's spatial optimizer:

  • Filter pushdown. When the column is a Box2D stored in GeoParquet, the predicate translates to Parquet row-group inequalities on the xmin / ymin / xmax / ymax leaves. See Box2D filter pushdown.
  • Spatial join. ST_Intersects(a, b) between two Box2D columns is planned as a range or broadcast-index join. See Box2D spatial join.