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_Box3D

Introduction: Return the planar 3D bounding box of a Geometry as a typed Box3D value (six doubles: xmin, ymin, zmin, xmax, ymax, zmax).

Geometries without a Z dimension fold into zmin = zmax = 0, matching PostGIS. ST_Box3D is the 3D counterpart to ST_Box2D; it always returns a Box3D value that serialises to a struct of six non-nullable doubles and round-trips through Parquet without WKB overhead.

ST_Box3D returns the tightest cuboid enclosing a geometry

Format: ST_Box3D(geom: Geometry)

Return type: Box3D

Since: v1.9.1

SQL Example

SELECT ST_AsText(ST_Box3D(ST_GeomFromWKT('LINESTRING Z(0 0 -3, 5 10 7)')))

Output:

BOX3D(0.0 0.0 -3.0, 5.0 10.0 7.0)

A 2D geometry folds its Z extent to 0:

SELECT ST_AsText(ST_Box3D(ST_GeomFromWKT('LINESTRING (0 0, 5 10)')))

Output:

BOX3D(0.0 0.0 0.0, 5.0 10.0 0.0)

ST_Box3D is also produced by the SQL cast CAST(geom AS box3d) — see Type conversion.

Returns NULL for NULL or empty geometry input.