Returns the Z coordinate of a point geometry as a float.
Syntax
float ST_Z(geometry aPoint);Parameters
| Parameter | Description |
|---|---|
aPoint | The point geometry from which to extract the Z coordinate. |
Usage notes
aPointmust 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.
该文章对您有帮助吗?