Box2D type in Sedona represents a planar axis-aligned bounding box — a rectangle described by four Double values: xmin, ymin, xmax, ymax. It is a first-class SQL type backed by a Spark UDT and serializes to a struct of four non-nullable doubles, so columns of Box2D round-trip natively through Parquet and align with GeoParquet 1.1 bbox covering columns.
Box2D complements the Geometry and Geography types. Use it when you need a compact, comparable bounding rectangle — for example, as a covering column on a GeoParquet table that lets the reader prune row groups, or as the join key in a spatial join that only needs an envelope-level match.
Semantic notes
Box2Dvalues use closed-interval semantics: edge-touching boxes are considered intersecting and contained (viaST_Intersects/ST_ContainsoverBox2Dinputs).- Absence is represented by SQL
NULLrather than an in-band sentinel. - Bounds are required to be ordered (
xmin <= xmax,ymin <= ymax). Inverted-bound values are reserved for a future antimeridian-wraparound semantics on geography bboxes; predicates and join planning throwIllegalArgumentExceptionon inverted input today. - Unlike ST_Envelope, which returns the envelope as a
Geometry(typically a polygon, but JTS may return aPointorLineStringfor degenerate inputs), ST_Box2D always returns a typedBox2Dvalue. Prefer the typed form when downstream code only needs the four bounds, and prefer the geometry form when downstream code expects aGeometry.
Constructors
Accessors
The same
ST_XMin / ST_YMin / ST_XMax / ST_YMax functions also accept Geometry inputs — see Bounding Box Functions.
Predicates
Box2D-on-Box2D overlap and containment are expressed through the standard ST_Intersects and ST_Contains predicates, which accept Box2D inputs directly with closed-interval semantics (ST_Intersects matches PostGIS && and ST_Contains matches PostGIS ~ on box2d).
Utility functions
Aggregates
Type conversion
Catalyst recognizes SQLCAST between Box2D and Geometry:
The cast forms require the Sedona SQL parser extension (
spark.sql.extensions=org.apache.sedona.sql.SedonaSqlExtensions); the function forms work in any Sedona-enabled session.
Query optimization
Box2D-typed columns are first-class participants in Sedona’s spatial optimizer:- Filter pushdown.
ST_Intersects/ST_Containspredicates over a Box2D column and a literal Box2D push down to Parquet row-group statistics on the column’s underlyingxmin/ymin/xmax/ymaxleaves. See Box2D filter pushdown. - Spatial joins.
ST_IntersectsandST_Containsover two Box2D columns route through the same physical operators (RangeJoinExec,BroadcastIndexJoinExec) used forGeometry. See Range join and Broadcast index join.

