ST_AddZ

更新时间:
复制 MD 格式

Sets the Z coordinate of a geometry to the value of the specified raster band.

Syntax

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

Parameters

ParameterDescription
sourceThe raster from which the geometry is converted.
geomThe geometry whose Z coordinate is set.
pyramidThe pyramid level of the raster. Valid values: 0 to N−1, where N is the number of pyramid levels. Default value: 0.
bandThe band of the raster. Valid values: 0 to N−1, where N is the number of bands. Default value: 0.

Description

Sets the Z coordinate of each point in the geometry to the value of the specified band at that point's location. If the raster is georeferenced, the function returns a geographic coordinate. If the raster is not georeferenced, the function returns a pixel coordinate.

Note

All points in 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)