All Products
Search
Document Center

PolarDB:ST_AsBox3D

Last Updated:Mar 28, 2026

Returns the box3d bounding box of a 3D geographic grid object.

Syntax

box ST_AsBox3D(geomgrid grid);
box[] ST_AsBox3D(geomgrid[] grid);

Parameters

ParameterDescription
gridThe 3D geographic grid object to convert. Accepts a single geomgrid value or a geomgrid array.

Description

ST_AsBox3D returns the three-dimensional bounding box that encloses a geographic grid object. The return type is box3d, which represents the minimum bounding volume in 3D space defined by two corner coordinates: (xmin, ymin, zmin) and (xmax, ymax, zmax).

  • When grid is a single geomgrid, the function returns a single box3d value.

  • When grid is a geomgrid array, the function returns a box3d array with one bounding box per grid cell.

Use this function with ST_As3DGrid to convert 3D grid cells into queryable spatial ranges.

Examples

Example 1: Return the bounding box of a single grid cell derived from a 3D point geometry at level 20.

SELECT ST_AsBox3D(unnest(ST_As3DGrid(
  'srid=4490;POINT(116.31522216796875 39.910277777777778 1001.8)'::geometry, 20)));

Output:

                                   st_asbox3d
--------------------------------------------------------------------------------
 BOX3D(116.315 39.91 970.027683307417,116.315555555556 39.9105555555556 1023.92243561707)

Example 2: Return the bounding boxes of all grid cells that intersect a 3D line geometry at level 10.

SELECT ST_AsBox3D(ST_As3DGrid(
'srid=4490;LINESTRING Z (116 39 2000,116.012 39.009 3000)'::geometry, 10));

Output:

                                                                              st_asbox3d
------------------------------------------------------------------------------------------------------------------------------

 {"BOX3D(115.533333333333 38.5333333333333 0,116 39 55418.9804682462)","BOX3D(115.533333333333 39 0,116 39.5333333333333 55418.9804682462)",
 "BOX3D(116 38.5333333333333 0,116.533333333333 39 55418.9804682462)","BOX3D(116 39 0,116.533333333333 39.5333333333333 55418.9804682462)"}

The result is an array of four box3d values, one for each grid cell that covers the input line.