Fork me on GitHub

ST_Z

Signature

DOUBLE ST_Z(GEOMETRY geom);

Description

Returns the z-value of the first coordinate of geom.

Implements the OpenGIS Simple Features Implementation Specification for SQL version 1.2.1.

Examples

SELECT ST_Z('LINESTRING(2 1 0, 1 3 3, 5 2 1)');
-- Answer: 0.0

SELECT ST_Z('POLYGON((5 0 2, 7 0 4, 7 1 3, 5 1 6, 5 0 1))');
-- Answer: 2.0

SELECT ST_Z(
    ST_PointN(
        ST_ExteriorRing(
            'POLYGON((5 0 2, 7 0 4, 7 1 3, 5 1 6, 5 0 1))'), 3));
-- Answer: 3.0

SELECT ST_Z('GEOMETRYCOLLECTION(
               LINESTRING(2 1 0, 1 3 3, 5 2 1),
               MULTIPOINT((4 4 3), (1 1 1), (1 0 2), (0 3 6)),
               POLYGON((1 2 2, 4 2 5, 4 6 3, 1 6 1, 1 2 1)))');
-- Answer: 0.0
See also