ST_MinZ function

The ST_MinZ function takes a geometry as an input parameter and returns its minimum Z coordinate.

If the given geometry is null or is empty, or if it does not have Z coordinates, then null is returned.

This function can also be called as a method.

Syntax

Read syntax diagramSkip visual syntax diagramdb2gse.ST_MinZ(geometry)

Parameter

geometry
A value of type ST_Geometry or one of its subtypes for which the minimum Z coordinate is returned.

Return type

DOUBLE

Examples

Example 1
This example illustrates the use of the ST_MinZ function. Three polygons are created and inserted into the SAMPLE_POLYS table.

SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse
CREATE TABLE sample_polys (id INTEGER, geometry ST_Polygon)

INSERT INTO sample_polys
  VALUES (1, ST_Polygon('polygon zm ((110 120 20 3,
                                      110 140 22 3,
                                      120 130 26 4,
                                      110 120 20 3))', 0) )

INSERT INTO sample_polys
  VALUES (2, ST_Polygon('polygon zm ((0 0 40 7,
                                      0 4 35 9,
                                      5 4 32 12,
                                      5 0 31 5,
                                      0 0 40 7))', 0) )

INSERT INTO sample_polys
  VALUES (3, ST_Polygon('polygon zm ((12 13 10 16,
                                       8 4 10 12,
                                       9 4 12 11,
                                      12 13 10 16))', 0) )
Example 2
This example finds the minimum Z coordinate of each polygon in SAMPLE_POLYS.

SELECT id, CAST ( ST_MinZ(geometry) AS INTEGER) MIN_Z
  FROM sample_polys
Results:

ID          MIN_Z
----------- ------------
          1           20
          2           31
          3           10
Example 3
This example finds the minimum Z coordinate that exists for all polygons in the GEOMETRY column.

SELECT CAST ( MIN ( ST_MinZ(geometry) ) AS INTEGER) OVERALL_MIN_Z
  FROM sample_polys
Results:

OVERALL_MIN_Z
--------------
             10