All Products
Search
Document Center

PolarDB:ST_AsBox3D

Last Updated:Mar 28, 2026

Returns the spatial range of a 3D geographic grid as a box3d value.

Syntax

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

Parameters

ParameterDescription
gridThe geographic grid object to convert. Accepts a single geomgrid or a geomgrid[] array.

Description

ST_AsBox3D converts a geomgrid object (or array of geomgrid objects) into the corresponding box3d bounding box.

The box3d value has the format BOX3D(xmin ymin zmin, xmax ymax zmax), where the first set of coordinates is the minimum corner and the second set is the maximum corner of the 3D extent.

Examples

Get the bounding box of a single 3D grid cell (POINT input)

Use unnest to expand the grid array returned by ST_As3DGrid, then pass each cell to ST_AsBox3D.

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

Result:

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

Get the bounding boxes of all grid cells covering a 3D line (LINESTRING input)

When the input geometry spans multiple grid cells, ST_As3DGrid returns a geomgrid[] array. Passing the array directly to ST_AsBox3D returns a box3d[] array — one bounding box per cell.

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

Result:

{"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)"}

What's next

  • ST_As3DGrid: Generate geomgrid objects from a geometry to use as input for ST_AsBox3D.