All Products
Search
Document Center

ApsaraDB RDS:ST_SetValue

Last Updated:Mar 28, 2026

Sets the pixel value of a raster object at a specified location, identified either by row and column or by a geometry shape.

Syntax

Overload 1: set by row and column

raster ST_SetValue(raster raster_obj,
                   integer row,
                   integer column,
                   double value,
                   integer band);

Overload 2: set by geometry

raster ST_SetValue(raster raster_obj,
                   geometry geom,
                   double value,
                   integer band default 0,
                   boolean rebuild_pyd default true,
                   cstring setvalueOptions default '');

Parameters

ParameterTypeDescription
raster_objrasterThe raster object to update.
rowintegerThe row number of the pixel to update.
columnintegerThe column number of the pixel to update.
valuedoubleThe new pixel value.
bandintegerThe band number of the pixel to update.
geomgeometryThe geometry that defines the region in which pixel values are updated.
rebuild_pydbooleanSpecifies whether to rebuild the pyramid after updating pixel values.
setvalueOptionscstringAdditional options for the update operation, passed as a JSON string. See the following table for supported fields.

setvalueOptions fields

FieldTypeDefaultDescription
window_clipboolfalseSpecifies whether to use the bounding box of the geometry object as the update region. true uses the minimum bounding rectangle (MBR) of the geometry object. false uses the geometry object itself.
rast_coordboolfalseSpecifies whether the input geometry uses pixel coordinates. true means pixel coordinates are used, where the x-coordinate maps to the column number and the y-coordinate maps to the row number, both starting from 0. false means pixel coordinates are not used.

Examples

Read the pixel value at row 0, column 2, band 1:

SELECT ST_Value(rast, 0, 2, 1) FROM raster_table ORDER BY id;

Set pixel values to 250.0 at the locations defined by a MULTIPOINT geometry on band 0, with pyramid rebuild enabled:

UPDATE raster_table
SET rast = ST_SetValue(rast, ST_GeomFromText('MULTIPOINT(0 0, 2 2, 10 10)', 4326), 250.0, 0, true);

Set pixel values to 10.0 along a LINESTRING using pixel coordinates (rast_coord: true), without rebuilding the pyramid:

UPDATE raster_table
SET rast = ST_SetValue(rast, ST_GeomFromText('LINESTRING(211 77, 233 100)', 4326), 10.0, 0, false, '{"rast_coord":true}');