ST_{X|Y|Z|T}Min

更新时间:
复制 MD 格式

Returns the minimum boundary value of a boxndf bounding box along the X, Y, Z, or T dimension.

Syntax

float8    ST_XMin(boxndf box);
float8    ST_YMin(boxndf box);
float8    ST_ZMin(boxndf box);
timestamp ST_TMin(boxndf box);
FunctionReturnsDescription
ST_XMinfloat8Minimum X coordinate of the bounding box
ST_YMinfloat8Minimum Y coordinate of the bounding box
ST_ZMinfloat8Minimum Z coordinate of the bounding box
ST_TMintimestampEarliest timestamp of the bounding box

Parameters

ParameterTypeDescription
boxboxndfThe bounding box to query

Usage notes

The functions behave differently depending on whether the requested dimension exists in the bounding box:

  • X, Y, or Z dimension missing — returns NaN.

  • T dimension missing — returns -infinity.

Before calling a Min function, verify that the bounding box has the target dimension. Calling ST_ZMin on a 2D+T box returns NaN, not an error. Calling ST_TMin on a 2D box returns -infinity, not an error.

To check whether a dimension exists before querying its minimum value, use the corresponding dimension accessor or spatial constructor that matches your box type. For example, ST_MakeBox2dt creates a box with X, Y, and T dimensions but no Z dimension.

Examples

Example 1: Query the minimum X value of a 2D+time bounding box

select ST_xmin(ST_MakeBox2dt(0,0,'2000-01-01'::timestamp, 20,20, '2020-01-01'::timestamp));
 st_xmin
---------
       0

Example 2: Query the minimum Z value of a 2D+time bounding box

The box was created with ST_MakeBox2dt, which has no Z dimension, so the result is NaN.

select ST_zmax(ST_MakeBox2dt(0,0,'2000-01-01'::timestamp, 20,20, '2020-01-01'::timestamp));
 st_zmin
---------
     NaN
-- NaN indicates the Z dimension does not exist in this bounding box.

Example 3: Query the minimum T value of a 2D bounding box

The box was created with ST_MakeBox2d, which has no T dimension, so the result is -infinity.

select ST_tmax(ST_MakeBox2d(0,0, 20,20));
  st_tmin
-----------
 -infinity
-- -infinity indicates the T dimension does not exist in this bounding box.