All Products
Search
Document Center

AnalyticDB:ST_MakeBox{Z|T|2D|2DT|3D|3DT}

Last Updated:Mar 28, 2026

Constructs a boxndf bounding box from explicit coordinate and timestamp bounds. Use these functions to define a search region for spatial index queries or spatiotemporal range filters.

Syntax

-- Single-axis (elevation)
boxndf ST_MakeBoxZ(float8 zmin, float8 zmax);

-- Single-axis (time)
boxndf ST_MakeBoxT(timestamp tmin, timestamp tmax);

-- 2D spatial
boxndf ST_MakeBox2D(float8 xmin, float8 ymin, float8 xmax, float8 ymax);

-- 2D spatial + time
boxndf ST_MakeBox2DT(float8 xmin, float8 ymin, timestamp tmin, float8 xmax, float8 ymax, timestamp tmax);

-- 3D spatial
boxndf ST_MakeBox3D(float8 xmin, float8 ymin, float8 zmin, float8 xmax, float8 ymax, float8 zmax);

-- 3D spatial + time
boxndf ST_MakeBox3DT(float8 xmin, float8 ymin, float8 zmin, timestamp tmin, float8 xmax, float8 ymax, float8 zmax, timestamp tmax);

Parameters

ParameterDescription
xminLower bound on the x-axis.
xmaxUpper bound on the x-axis.
yminLower bound on the y-axis.
ymaxUpper bound on the y-axis.
zminLower bound on the z-axis.
zmaxUpper bound on the z-axis.
tminLower bound on the t-axis (earliest timestamp).
tmaxUpper bound on the t-axis (latest timestamp).

The min parameters define the lower-left corner of the bounding box; the max parameters define the upper-right corner.

Return value

All variants return a boxndf value.

Because boxndf stores coordinates as float8 (64-bit floating-point), the returned bounding box may be slightly larger than the values you pass in: the lower bound may be slightly smaller than specified, and the upper bound may be slightly larger. This is expected behavior — spatial index lookups remain correct.

Examples

Create a 2D bounding box

The following example creates a 2D bounding box and returns it in BOX2D format.

SELECT ST_MakeBox2D(0, 0, 3, 3);
  st_makebox2d
----------------
 BOX2D(0 0,3 3)

Create a 3D spatiotemporal bounding box

The following example creates a bounding box with three spatial dimensions and a time range, then returns it in BOX3DT format. The output timestamps show the float rounding effect described above.

SELECT ST_MakeBox3DT(0, 0, 3, '2000-01-01 00:00:03'::timestamp, 2, 5, 4, '2000-01-01 02:46:40'::timestamp);
                              st_makebox3dt
---------------------------------------------------------------------------
 BOX3DT(0 0 3 2000-01-01 00:00:02.999999,2 5 4 2000-01-01 02:46:40.000476)
(1 row)