Expands a bounding box outward by a uniform distance in all spatial dimensions.
Syntax
boxndf ST_ExpandSpatial(boxndf box, float8 len);Parameters
| Parameter | Type | Description |
|---|---|---|
box | boxndf | The bounding box to expand. |
len | float8 | The distance by which to expand the bounding box. Each lower bound is decreased by this value, and each upper bound is increased by this value. |
Description
ST_ExpandSpatial expands a boxndf bounding box outward by len units along each spatial axis (x, y, and z where present). The time dimension is not affected.
Use this function to add a buffer around a bounding box for spatial index filtering or proximity queries. For example, to find all geometries within 5 units of a query point, expand the point's bounding box by 5 before applying an index filter.
Example
Expand a 2D bounding box with a time range (BOX2DT) by 4 units:
SELECT ST_ExpandSpatial(ST_MakeBox2dt(0, 0, '2000-01-02', 20, 20, '2000-03-03'), 4);Output:
st_expandspatial
-------------------------------------------------------------
BOX2DT(-4 -4 2000-01-02 00:00:00,24 24 2000-03-03 00:00:00)The input box spans x=[0, 20] and y=[0, 20]. After expanding by 4, x becomes [-4, 24] and y becomes [-4, 24]. The time range ['2000-01-02', '2000-03-03'] is unchanged.
What's next
ST_MakeBox2dt — Create a 2D bounding box with a time dimension