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 to evaluate. |
Usage notes
The parameter type is defined as
box3d, but auto-casting lets the function accept Box2D and geometry objects as well. String representations of Box2D and geometry objects are not supported by auto-casting — pass them with an explicit cast instead.ST_ZMin preserves z-coordinates and does not drop them from 3D objects.
ST_ZMin supports circular strings and curves.
Examples
Get the minimum z-coordinate of a LineString
Pass a geometry object using the ::geometry cast:
SELECT ST_ZMin('LINESTRING(0 1 2,3 4 5)'::geometry);
st_zmin
---------
2
(1 row)Get the minimum z-coordinate of a BOX3D
Pass a BOX3D literal directly:
SELECT ST_ZMin('BOX3D(1 2 3,4 5 6)'::box3d);
st_zmin
---------
3
(1 row)Get the minimum z-coordinate of a CircularString
SELECT ST_ZMin(ST_GeomFromEWKT('CIRCULARSTRING(220268 150415 1,220227 150505 2,220227 150406 3)'));
st_zmin
---------
1
(1 row)String literals without a cast fail
Passing a plain string without an explicit cast raises a parser error because auto-casting does not apply to string representations:
-- This does NOT work
SELECT ST_ZMin('LINESTRING(0 1 2,3 4 5)');
-- ERROR: BOX3D parser - doesn't start with BOX3D(Use ST_GeomFromEWKT or an explicit ::geometry cast to avoid this error:
SELECT ST_ZMin(ST_GeomFromEWKT('LINESTRING(0 1 2,3 4 5)'));
st_zmin
---------
2
(1 row)Related functions
[ST_ZMax](): Returns the maximum z-coordinate of a bounding box.
[ST_XMin](): Returns the minimum x-coordinate of a bounding box.
[ST_XMax](): Returns the maximum x-coordinate of a bounding box.
[ST_YMin](): Returns the minimum y-coordinate of a bounding box.
[ST_YMax](): Returns the maximum y-coordinate of a bounding box.