Do you remember ST_Reclass
? How about getting good classes? There are two very interesting tools in PostGIS. ST_Histogram()
and ST_Quantile()
. First, return SETOF
record of the defined number of histogram bins. The only thing we need to set is the raster column, band, and number of bins. We can break results into min
, max
, count
, and percent
with SELECT (histogram).*
syntax.
mastering_postgis=# SELECT (stat).* FROM (SELECT ST_Histogram(rast,1,6) AS stat FROM eudem.clip) AS foo; min | max | count | percent ------------------+------------------+-------+--------------------- 440.980010986328 | 549.598332722982 | 19517 | 0.103899491602119 549.598332722982 | 658.216654459635 | 76015 | 0.404668742846496 658.216654459635 | 766.834976196289 | 55312 | 0.29445553514866 766.834976196289 | 875.453297932943 | 26941 | 0.14342143788762 875.453297932943 | 984.071619669597 | 8320 | 0.0442918363544412 984.071619669597...