Definition
ST_Z takes an ST_Point as an input parameter and returns its z- (elevation) coordinate. In SQLite, ST_Z can also update the z-coordinate of an ST_Point.
Syntax
Oracle and PostgreSQL
sde.st_z (geometry1 sde.st_point)
SQLite
st_z (geometry geometryblob) st_z (input_shape geometryblob, new_Zvalue double)
Return type
Oracle
Number
PostgreSQL
Integer
SQLite
Double precision is returned when ST_Z is used to return the z-coordinate of a point. A geometryblob is returned when ST_Z is used to update the z-coordinate of a point.
Example
The z_test table is created with two columns: the id column, which uniquely identifies the row, and the geometry point column. The INSERT statement inserts a row into the z_test table.
The SELECT statement lists the id column and the double-precision z-coordinate of the point inserted with the previous statement.
Oracle
CREATE TABLE z_test (
id integer unique,
geometry sde.st_point
);
INSERT INTO z_test (id, geometry) VALUES (
1,
sde.st_point (2, 3, 32, 5, 4326)
);
SELECT id, sde.st_z (geometry) Z_COORD
FROM Z_TEST;
ID Z_COORD
1 32
PostgreSQL
CREATE TABLE z_test (
id integer unique,
geometry sde.st_point
);
INSERT INTO z_test (id, geometry) VALUES (
1,
sde.st_point (2, 3, 32, 5, 4326)
);
SELECT id, sde.st_z (geometry)
AS Z_COORD
FROM z_test;
id z_coord
1 32
SQLite
CREATE TABLE z_test (id integer);
SELECT AddGeometryColumn(
NULL,
'z_test',
'pt1',
4326,
'pointzm',
'xyzm',
'null'
);
INSERT INTO z_test (id, pt1) VALUES (
1,
st_point (2, 3, 32, 5, 4326)
);
SELECT id, st_z (pt1)
AS "The z coordinate"
FROM z_test;
id The z coordinate
1 32.0
The ST_Z function can also be used to update the coordinate value of an existing point. In this example, ST_Z is used to update the z-coordinate value of the first point in z_test.
UPDATE z_test
SET pt1=st_z(
(SELECT pt1 FROM z_test where id=1), 32.04)
WHERE id=1;