From: Regina Obe Date: Tue, 31 May 2011 00:54:01 +0000 (+0000) Subject: Document ST_SummaryStats raster function X-Git-Tag: 2.0.0alpha1~1517 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=164a53f0c37758c22dabbb597c3a6f9dc08c27b2;p=postgis Document ST_SummaryStats raster function git-svn-id: http://svn.osgeo.org/postgis/trunk@7297 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/doc/reference_raster.xml b/doc/reference_raster.xml index 652b5d713..85917a106 100644 --- a/doc/reference_raster.xml +++ b/doc/reference_raster.xml @@ -3326,6 +3326,105 @@ ORDER BY value, quantile,rid + + + ST_SummaryStats + Returns summary stats consisting of count,sum,mean,stddev,min,max for a given raster band of a raster or raster coverage. + + + + + + summarystats ST_SummaryStats + raster rast + integer nband=1 + boolean exclude_nodata_value=true + double precision sample_percent=1 + + + + summarystats ST_SummaryStats + raster rast + boolean exclude_nodata_value + + + + summarystats ST_SummaryStats + text rastertable + text rastercolumn + integer nband=1 + boolean exclude_nodata_value=true + double precision sample_percent=1 + + + + summarystats ST_SummaryStats + text rastertable + text rastercolumn + boolean exclude_nodata_value + + + + + + + Description + + Returns summarystats consisting of count, sum, mean, stddev, min, max for a given raster band of a raster or raster coverage.. If no band is specified nband defaults to 1. + By default only considers pixel values no equal to the nodata value . Set exclude_nodata_value to false to get count all pixels. By default will sample all pixels. To get faster response, set sample_percent to lower than 1 + Availability: 2.0.0 + + + + Example: Single raster tile + +SELECT rid, band, (stats).* +FROM (SELECT rid, band, ST_SummaryStats(rast, band) As stats + FROM dummy_rast CROSS JOIN generate_series(1,3) As band + WHERE rid=2) As foo; + + rid | band | count | sum | mean | stddev | min | max +-----+------+-------+------+------------+-----------+-----+----- + 2 | 1 | 23 | 5821 | 253.086957 | 1.248061 | 250 | 254 + 2 | 2 | 25 | 3682 | 147.28 | 59.862188 | 78 | 254 + 2 | 3 | 25 | 3290 | 131.6 | 61.647384 | 62 | 254 + + + + + Example: Raster coverage + +-- stats for each band -- +SELECT band, (stats).* +FROM (SELECT band, ST_SummaryStats('o_4_boston','rast', band) As stats + FROM generate_series(1,3) As band) As foo; + + band | count | sum | mean | stddev | min | max +------+---------+--------+------------------+------------------+-----+----- + 1 | 8450000 | 725799 | 82.7064349112426 | 45.6800222638537 | 0 | 255 + 2 | 8450000 | 700487 | 81.4197705325444 | 44.2161184161765 | 0 | 255 + 3 | 8450000 | 575943 | 74.682739408284 | 44.2143885481407 | 0 | 255 + +-- For a table -- will get better speed if set sampling to less than 100% +-- Here we set to 25% and get a much faster answer +SELECT band, (stats).* +FROM (SELECT band, ST_SummaryStats('o_4_boston','rast', band,true,0.25) As stats + FROM generate_series(1,3) As band) As foo; + + band | count | sum | mean | stddev | min | max +------+---------+--------+------------------+------------------+-----+----- + 1 | 2112500 | 180686 | 82.6890480473373 | 45.6961043857248 | 0 | 255 + 2 | 2112500 | 174571 | 81.448503668639 | 44.2252623171821 | 0 | 255 + 3 | 2112500 | 144364 | 74.6765884023669 | 44.2014869384578 | 0 | 255 + + + + + See Also + + + + ST_ValueCount