This topic describes the ST_SummaryStats function. This function is used to calculate the statistics of a specified set of bands that are contained 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

Parameter Description
raster_obj The name of the raster object.
bands The sequence numbers of the bands. The value of this parameter can be an array of integers or an integer range. The integers start from 0. Examples:
  • '0'
  • '1-3'
  • '1,2,3'
statsOptions The JSON string to specify the statistics that you want to calculate.

The following table describes the parameter that is contained in the value of the statsOptions parameter.

Parameter Description Type Format Default value Remarks
approx Specifies whether to use the sampling method to calculate statistics. boolean None true
  • true: specifies to use the sampling method to calculate statistics. The statistics may be inaccurate.
  • false: specifies to calculate all statistics.

Examples:

Calculate the statistics for a specified set of bands that are contained in a raster object.

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;