This topic describes the ST_AddZ function. This function specifies the Z coordinate of a geometry based on the band of the raster that is converted from the geometry.

Syntax

geometry ST_AddZ(raster source,
                 geometry geom,
                 integer pyramid,
                 integer band);

Parameters

Parameter Description
source The raster from which the geometry is converted.
geom The geometry whose Z coordinate you want to specify.
pyramid The pyramid level of the raster. Valid values start from 0. If the number of layers in the pyramid is N, the value of this parameter is an integer that ranges from 0 to the difference between N and 1. Default value: 0.
band The band of the raster. Valid values start from 0. If the number of bands of the raster is N, the value of this parameter is an integer that ranges from 0 to the difference between N and 1. Default value: 0.

Description

This function specifies the Z coordinate of a geometry based on the band of the raster that is converted from the geometry. If the raster is georeferenced, this function returns a geographic coordinate of the geometry. If the raster is not georeferenced, this function returns a pixel coordinate of the geometry.

Note All of the points on the geometry must fall within the raster.

Examples

SELECT ST_AddZ(rast_object, ST_GeomFromText('POINT(120.5 30.6)', 4326), 0, 0)
FROM raster_table;

------------------------
POINT Z(120.5 30.6 27)

SELECT ST_AddZ(rast_object, ST_GeomFromText('POINT(120.5 30.6)', 4326), 1, 1)
FROM raster_table;

------------------------
POINT Z(120.5 30.6 115)