All Products
Search
Document Center

PolarDB:ST_SummaryStats

Last Updated:Mar 28, 2026

Calculates statistics for a specified set of bands in a raster object.

Syntax

raster ST_SummaryStats(raster raster_obj)
raster ST_SummaryStats(raster raster_obj, cstring statsOption)
raster ST_SummaryStats(raster raster_obj,
                       cstring bands,
                       cstring statsOption)

Parameters

ParameterDescription
raster_objThe name of the raster object.
bandsThe sequence numbers of the bands. Accepts an array of integers or an integer range. Sequence numbers start from 0. Examples: '0', '1-3', '1,2,3'.
statsOptionsA JSON string specifying the statistics to calculate.

The statsOptions parameter accepts the following field:

FieldTypeDefaultDescription
approxBooleantrueSpecifies whether to use the sampling method to calculate statistics. true: uses sampling, results may be approximate. false: calculates all statistics.

Examples

UPDATE raster_obj SET raster_obj=ST_SummaryStats(raster_obj) WHERE id = 1;
UPDATE rast SET rast=ST_SummaryStats(rast,'0-2','{"approx":false}') WHERE id = 1;
UPDATE rast SET rast=ST_SummaryStats(rast,'{"approx":false}') WHERE id = 1;