ST_SummaryStats

Updated at:

Calculates the statistics of a specified set of bands of 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 raster object.

bands

The specified band numbers. Band numbers start from 0. The format is '0' , '1-3' , or '1,2,3' .

statsOptions

The JSON string of statistics options.

statsOptions is used to specify the statistics parameters. The parameters are as follows:

Parameter

Description

Type

Format

Default value

Description details

approx

Specifies whether to use sampling to calculate statistics.

boolean

None

true

  • true: Statistics are calculated by sampling. The results may be inaccurate.

  • false: All statistics are calculated.

Example

Calculate the statistics of a specified set of bands of 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;