Returns the minimum z coordinate of the bounding box of a Box2D, Box3D, or geometry object.
Syntax
float ST_ZMin(box3d aGeomorBox2DorBox3D);Parameters
| Parameter | Description |
|---|---|
aGeomorBox2DorBox3D | The Box2D, Box3D, or geometry object. |
Usage notes
Although the parameter type is defined asbox3d, ST_ZMin also accepts Box2D and geometry values through auto-casting. However, passing a Box2D or geometry value as a string literal bypasses auto-casting and causes an error. UseST_GeomFromEWKTor a cast expression (::geometry) to convert string input explicitly.
Additional behavior:
Preserves z coordinates — does not drop the z dimension from 3D objects.
Supports circular strings and curves.
Examples
Get the minimum z coordinate of a LineString
SELECT ST_ZMin('LINESTRING(0 1 2,3 4 5)'::geometry);
st_zmin
---------
2
(1 row)Get the minimum z coordinate of a Box3D
SELECT ST_ZMin('BOX3D(1 2 3, 4 5 6)');
st_zmin
---------
3
(1 row)Use ST_GeomFromEWKT to pass a geometry string
SELECT ST_ZMin(ST_GeomFromEWKT('LINESTRING(1 3 4, 5 6 7)'));
st_zmin
---------
4
(1 row)Passing a geometry string directly causes an error
-- This fails because the string does not auto-cast to box3d
SELECT ST_ZMin('LINESTRING(1 3 4, 5 6 7)');
-- ERROR: BOX3D parser - doesn't start with BOX3D(What's next
该文章对您有帮助吗?