From: Bborie Park Date: Sat, 14 Dec 2013 20:54:50 +0000 (+0000) Subject: Added docs for ST_SummaryStatsAgg() X-Git-Tag: 2.2.0rc1~1282 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cac635d6ccce9e50b4710ab78960e98dbeff9dbd;p=postgis Added docs for ST_SummaryStatsAgg() git-svn-id: http://svn.osgeo.org/postgis/trunk@12160 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/NEWS b/NEWS index c2216e658..9309047f4 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,8 @@ PostGIS 2.2.0 * Deprecated signatures * + - #2565, ST_SummaryStats(tablename, rastercolumn, ...) + * New Features * - #2430, ST_ForceCurve diff --git a/doc/reference_raster.xml b/doc/reference_raster.xml index e97ff2773..f9bc5f03a 100644 --- a/doc/reference_raster.xml +++ b/doc/reference_raster.xml @@ -284,6 +284,103 @@ VALUES (1, + + + summarystats + A composite type returned by the ST_SummaryStats and ST_SummaryStatsAgg functions. + + + + Description + + A composite type returned by the and functions. + + + + + count + integer + + + + Number of pixels counted for the summary statistics. + + + + + + + sum + double precision + + + + Sum of all counted pixel values. + + + + + + + mean + double precision + + + + Arithmetic mean of all counted pixel values. + + + + + + + stddev + double precision + + + + Standard deviation of all counted pixel values. + + + + + + + min + double precision + + + + Minimum value of counted pixel values. + + + + + + + max + double precision + + + + Maximum value of counted pixel values. + + + + + + + + + + + See Also + + , + + + + unionarg @@ -6735,7 +6832,8 @@ FROM (SELECT rid, ST_Histogram(rast, 2,6,ARRAY[0.5,1,4,100,5]) As stats See Also , - + , + @@ -6886,46 +6984,51 @@ ORDER BY value, quantile,rid See Also - , + + , + , + , + + ST_SummaryStats - Returns record consisting of count, sum, mean, stddev, min, max for a given raster band of a raster or raster coverage. Band 1 is assumed is no band is specified. + Returns summarystats consisting of count, sum, mean, stddev, min, max for a given raster band of a raster or raster coverage. Band 1 is assumed is no band is specified. - record ST_SummaryStats - text rastertable - text rastercolumn + summarystats ST_SummaryStats + raster rast boolean exclude_nodata_value - - - record ST_SummaryStats + + + summarystats ST_SummaryStats raster rast + integer nband boolean exclude_nodata_value - + - record ST_SummaryStats + summarystats ST_SummaryStats + text rastertable + text rastercolumn + boolean exclude_nodata_value + + + + summarystats ST_SummaryStats text rastertable text rastercolumn integer nband=1 boolean exclude_nodata_value=true - - record ST_SummaryStats - raster rast - integer nband - boolean exclude_nodata_value - - @@ -6933,12 +7036,20 @@ ORDER BY value, quantile,rid Description - Returns record 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. + Returns 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 not equal to the nodata value. Set exclude_nodata_value to false to get count of all pixels. By default will sample all pixels. To get faster response, set sample_percent to lower than 1 + Availability: 2.0.0 + + + + The ST_SummaryStats(rastertable, rastercolumn, ...) variants are deprecated as of 2.2.0. Use instead. + + + @@ -7023,12 +7134,115 @@ FROM (SELECT band, ST_SummaryStats('o_4_boston','rast', band,true,0.25) As stats See Also -, - + , + , + , + + + + + ST_SummaryStatsAgg + Aggregate. Returns summarystats consisting of count, sum, mean, stddev, min, max for a given raster band of a set of raster. Band 1 is assumed is no band is specified. + + + + + summarystats ST_SummaryStatsAgg + raster rast + integer nband + boolean exclude_nodata_value + double precision sample_percent + + + + summarystats ST_SummaryStatsAgg + raster rast + boolean exclude_nodata_value + double precision sample_percent + + + + summarystats ST_SummaryStatsAgg + raster rast + integer nband + boolean exclude_nodata_value + + + + + + Description + + Returns 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 not equal to the NODATA value. Set exclude_nodata_value to False to get count of all pixels. + + By default will sample all pixels. To get faster response, set sample_percent to value between 0 and 1 + + Availability: 2.2.0 + + + + Examples + +WITH foo AS ( + SELECT + rast.rast + FROM ( + SELECT ST_SetValue( + ST_SetValue( + ST_SetValue( + ST_AddBand( + ST_MakeEmptyRaster(10, 10, 10, 10, 2, 2, 0, 0,0) + , 1, '64BF', 0, 0 + ) + , 1, 1, 1, -10 + ) + , 1, 5, 4, 0 + ) + , 1, 5, 5, 3.14159 + ) AS rast + ) AS rast + FULL JOIN ( + SELECT generate_series(1, 10) AS id + ) AS id + ON 1 = 1 +) +SELECT + (stats).count, + round((stats).sum::numeric, 3), + round((stats).mean::numeric, 3), + round((stats).stddev::numeric, 3), + round((stats).min::numeric, 3), + round((stats).max::numeric, 3) +FROM ( + SELECT + ST_SummaryStatsAgg(rast, 1, TRUE, 1) AS stats + FROM foo +) bar; + + count | round | round | round | round | round +-------+---------+--------+-------+---------+------- + 20 | -68.584 | -3.429 | 6.571 | -10.000 | 3.142 +(1 row) + + + + + See Also + + , + , + , + + + + + ST_ValueCount