All Products
Search
Document Center

ApsaraDB RDS:ST_SummaryStats

Last Updated:Mar 28, 2026

ST_SummaryStats calculates band statistics for a raster object.

Syntax

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

Parameters

ParameterDescription
raster_objThe raster object to analyze.
bandsThe bands to include, specified as an integer array or range. Band indexes start at 0. Examples: '0', '1-3', '1,2,3'.
statsOptionsA JSON string specifying calculation options. See statsOptions fields below.

statsOptions fields

FieldTypeDefaultDescription
approxbooleantrueSpecifies whether to use sampling to calculate statistics.
By default, approx is true, which uses sampling to compute statistics faster. Results may be slightly inaccurate. Set approx to false to scan all pixels and get exact statistics.

Return value

Returns a raster object with statistics stored per band.

Examples

Calculate statistics for all bands using sampling (default)

UPDATE raster_obj SET raster_obj = ST_SummaryStats(raster_obj) WHERE id = 1;

Calculate exact statistics for a specific band range

Pass '{"approx":false}' to scan all pixels instead of sampling. The following example calculates exact statistics for bands 0 through 2:

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

Calculate exact statistics for all bands

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