ST_Z

更新时间:
复制 MD 格式

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.

Usage notes

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

  • Returns NULL if the input is unavailable or invalid.

  • Preserves Z coordinates on 3D objects — the function does not strip or modify the Z value.

Examples

Return the Z coordinate of a 3D point:

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

The input POINT(0 1 2 3) uses the WKT format where the third value (2) is the Z coordinate. ST_Z returns 2 as a float.