Skip to main content
Return true if A fully contains B. Polymorphic over input type:
  • (Geometry, Geometry) — topological containment via JTS.
  • (Geography, Geography) — topological containment via S2.
  • (Box2D, Box2D) — closed-interval bbox containment on both axes (PostGIS ~ on box2d). Throws IllegalArgumentException on inverted bounds. See Box2D optimization below.
  • (Box3D, Box3D) — closed-interval bbox containment on all three axes. Throws on inverted bounds on any axis.
ST_Contains returning true ST_Contains returning false

Signatures

Parameters

A
Geometry | Geography | Box2D | Box3D
required
The containing input. Box2D / Box3D inputs use closed-interval semantics.
B
Geometry | Geography | Box2D | Box3D
required
The contained input, of the same type family as A.

Return type

true if A fully contains B.

Example

Box2D example:
For Box3D inputs containment must hold on all three axes — a box contained within another’s XY footprint but extending past it in Z is not contained: Box3D ST_Contains returning true: B lies fully inside A Box3D ST_Contains returning false: B is inside in XY but extends past A in Z

Box2D optimization

ST_Contains(box_col, lit_box) over a Box2D column and a literal Box2D (and the reversed form) is recognized 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_Contains(a, b) between two Box2D columns is planned as a range or broadcast-index join with COVERS semantics (closed-interval containment). See Box2D spatial join.