All Products
Search
Document Center

ApsaraDB RDS:ST_Z

Last Updated:Mar 28, 2026

Returns the Z coordinate of a point geometry as a float.

Syntax

float ST_Z(geometry aPoint);

Parameters

ParameterDescription
aPointThe point geometry from which to extract the Z coordinate.

Returns

Returns the Z coordinate as a float.

Returns NULL if the input is NULL or not a valid point geometry.

Usage notes

  • aPoint must be a point geometry. Passing any other geometry type returns NULL.

  • ST_Z preserves Z coordinates and does not strip them from 3D geometries.

Examples

Extract the Z coordinate from a 4D point

SELECT ST_Z('POINT(0 1 2 3)'::geometry);

Output:

 st_z
------
    2
(1 row)

The input point has coordinates x=0, y=1, z=2, m=3. ST_Z returns 2, the Z coordinate.

NULL and non-point input behavior

ST_Z returns NULL for both NULL input and non-point geometry types:

SELECT
    ST_Z(NULL),
    ST_Z('LINESTRING(0 0 1, 1 1 2)'::geometry);

Output:

 st_z | st_z
------+------
 NULL | NULL
(1 row)

See also

  • ST_X — returns the X coordinate of a point

  • ST_Y — returns the Y coordinate of a point