ST_{X|Y|Z|T}Max
Returns the maximum coordinate value of a bounding box along a specified dimension.
Syntax
float8 ST_XMax(boxndf box);
float8 ST_YMax(boxndf box);
float8 ST_ZMax(boxndf box);
timestamp ST_TMax(boxndf box);Parameters
| Parameter | Description |
|---|---|
box | The boxndf bounding box to query. |
Description
Each function extracts the upper bound of a boxndf bounding box along a single dimension:
ST_XMaxandST_YMaxreturn afloat8value. If the bounding box has no X or Y dimension, the function returnsNaN.ST_ZMaxreturns afloat8value. If the bounding box has no Z dimension, the function returnsNaN.ST_TMaxreturns atimestampvalue. If the bounding box has no T dimension, the function returns-infinity.
Use the return value to detect whether a dimension is present: NaN indicates a missing spatial dimension (X, Y, or Z); -infinity indicates a missing temporal dimension (T).
Examples
Query the maximum T value of a 2D+T bounding box
ST_MakeBox2dt creates a bounding box with X, Y, and T dimensions. Querying ST_TMax returns the upper timestamp bound.
select ST_tmax(ST_MakeBox2dt(0,0,'2000-01-01'::timestamp, 20,20, '2020-01-01'::timestamp));
st_tmax
---------------------
2020-01-01 00:00:00Query a missing dimension
The same bounding box has no Z dimension, so ST_ZMax returns NaN. A box with no T dimension returns -infinity from ST_TMax.
select ST_zmax(ST_MakeBox2dt(0,0,'2000-01-01'::timestamp, 20,20, '2020-01-01'::timestamp));
st_zmax
---------
NaN
select ST_tmax(ST_MakeBox2d(0,0, 20,20));
st_tmax
-----------
-infinityWhat's next
ST_{X|Y|Z|T}Min — returns the minimum coordinate value along a specified dimension
ST_MakeBox2d — creates a 2D bounding box from two points
ST_MakeBox2dt — creates a 2D+T bounding box from two spatiotemporal points