From: Regina Obe Date: Mon, 30 May 2011 02:52:07 +0000 (+0000) Subject: document ST_quantile -- still missing some protos (also get rid of obsolete warnings) X-Git-Tag: 2.0.0alpha1~1527 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=18faf8cbafe7e45cc31a26ea2e29651aa1283757;p=postgis document ST_quantile -- still missing some protos (also get rid of obsolete warnings) git-svn-id: http://svn.osgeo.org/postgis/trunk@7287 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/doc/reference_raster.xml b/doc/reference_raster.xml index 10355b003..6c470bb8e 100644 --- a/doc/reference_raster.xml +++ b/doc/reference_raster.xml @@ -1879,7 +1879,7 @@ SELECT (bmd).* FROM (SELECT ST_BandMetaData(rast,generate_series(1,2)) As bmd FROM dummy_rast WHERE rid = 10) AS foo; --result -- - pixeltype | exclude_nodata_valuevalue | nodatavalue | isoutdb | path + pixeltype | hasnodata | nodatavalue | isoutdb | path -----------+----------------+-------------+---------+------ 1BB | f | 0 | f | 4BUI | f | 0 | f | @@ -3129,6 +3129,121 @@ select st_bandisnodata(rast, 1) from dummy_rast where rid = 1; -- Expected true Raster Band Statistics and Analytics + + + + ST_Quantile + Compute quantiles in the context of the sample or population. Thus, a value could be examined to be at the raster's 25%, 50%, 75% percentile. + + + + + + SETOF quantile ST_Quantile + raster rast + integer nband=1 + boolean exclude_nodata_value=true + double precision[] quantiles=NULL + + + double precision ST_Quantile + raster rast + double precision quantile + + + double precision ST_Quantile + raster rast + boolean exclude_nodata_value + double precision quantile=NULL + + + double precision ST_Quantile + raster rast + integer nband + double precision quantile + + + double precision ST_Quantile + raster rast + integer nband + double precision quantile + + + + + + Description + + Compute quantiles in the context of the sample or population. Thus, a value could be examined to be at the raster's 25%, 50%, 75% percentile. + If exclude_nodata_value is set to true, will also count pixels with no data. Set exclude_nodata_value to false to get only pixels with data + Availability: 2.0.0 + + + + Examples + + +UPDATE dummy_rast SET rast = ST_SetBandNoDataValue(rast,249) WHERE rid=2; +--Example will consider only pixels of band 1 that are not 249 and in named quantiles -- + +SELECT (pvq).* +FROM (SELECT ST_Quantile(rast, ARRAY[0.25,0.75]) As pvq + FROM dummy_rast WHERE rid=2) As foo + ORDER BY (pvq).quantile; + + quantile | value +----------+------- + 0.25 | 253 + 0.75 | 254 + +SELECT ST_Quantile(rast, 0.75) As value + FROM dummy_rast WHERE rid=2; + +value +------ + 254 + + +--real live example. Quantile of all pixels in band 2 intersecting a geometry +SELECT rid, (ST_Quantile(rast,2)).* As pvc + FROM o_4_boston + WHERE ST_Intersects(rast, + ST_GeomFromText('POLYGON((224486 892151,224486 892200,224706 892200,224706 892151,224486 892151))',26986) + ) +ORDER BY value, quantile,rid +; + + + rid | quantile | value +-----+----------+------- + 1 | 0 | 0 + 2 | 0 | 0 + 14 | 0 | 1 + 15 | 0 | 2 + 14 | 0.25 | 37 + 1 | 0.25 | 42 + 15 | 0.25 | 47 + 2 | 0.25 | 50 + 14 | 0.5 | 56 + 1 | 0.5 | 64 + 15 | 0.5 | 66 + 2 | 0.5 | 77 + 14 | 0.75 | 81 + 15 | 0.75 | 87 + 1 | 0.75 | 94 + 2 | 0.75 | 106 + 14 | 1 | 199 + 1 | 1 | 244 + 2 | 1 | 255 + 15 | 1 | 255 + + + + + See Also + , + + ST_Count @@ -3232,7 +3347,6 @@ rid | exclude_nodata | include_nodata Returns the number of pixels in a given band of a raster or raster coverage. If no band is specified nband defaults to 1. If exclude_nodata_value is set to true, will also count pixels with no data. Set exclude_nodata_value to false to get only pixels with data Availability: 2.0.0 - This currently does the opposite of what I just said. Will be fixed to agree with the documentation or the documentation will be fixed to agree with the behavior. @@ -3289,6 +3403,25 @@ FROM (SELECT ST_ValueCount(rast,2) As pvc : + +--real live example. Count all the pixels in an aerial raster tile band 2 intersecting a geometry +-- and return only the pixel band values that have a count > 500 +SELECT (pvc).value, SUM((pvc).count) As total +FROM (SELECT ST_ValueCount(rast,2) As pvc + FROM o_4_boston + WHERE ST_Intersects(rast, + ST_GeomFromText('POLYGON((224486 892151,224486 892200,224706 892200,224706 892151,224486 892151))',26986) + ) + ) As foo + GROUP BY (pvc).value + HAVING SUM((pvc).count) > 500 + ORDER BY (pvc).value; + + value | total +-------+----- + 51 | 502 + 54 | 521 +