From: Bborie Park Date: Sat, 8 Sep 2012 01:24:35 +0000 (+0000) Subject: Added docs for new variant of ST_SetValues() X-Git-Tag: 2.1.0beta2~662 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=59c498815c0141e35426e5e0eff3ed39453d527b;p=postgis Added docs for new variant of ST_SetValues() git-svn-id: http://svn.osgeo.org/postgis/trunk@10261 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/doc/reference_raster.xml b/doc/reference_raster.xml index 8e17439c0..1608ad929 100644 --- a/doc/reference_raster.xml +++ b/doc/reference_raster.xml @@ -4024,6 +4024,17 @@ GROUP BY (foo.geomval).val; boolean keepnodata=FALSE + + raster ST_SetValues + raster rast + integer nband + integer columnx + integer rowy + double precision[][] newvalueset + double precision nosetvalue + boolean keepnodata=FALSE + + raster ST_SetValues raster rast @@ -4057,15 +4068,19 @@ GROUP BY (foo.geomval).val; - For variant 1, the specific pixels to be set are determined by the columnx, rowy pixel coordinates and the dimensions of the newvalueset array. noset can be used to prevent pixels with values present in newvalueset from being set (due to PostgreSQL not permitting ragged/jagged arrays). If keepnodata is TRUE, those pixels whose values are NODATA will not be set with the corresponding value in newvalueset. See example Variant 1. + For Variant 1, the specific pixels to be set are determined by the columnx, rowy pixel coordinates and the dimensions of the newvalueset array. noset can be used to prevent pixels with values present in newvalueset from being set (due to PostgreSQL not permitting ragged/jagged arrays). If keepnodata is TRUE, those pixels whose values are NODATA will not be set with the corresponding value in newvalueset. See example Variant 1. + + + + Variant 2 is like Variant 1 but with a simple double precision nosetvalue instead of a boolean noset array. Elements in newvalueset with the nosetvalue value with be skipped. See example Variant 2. - For variant 2, the specific pixels to be set are determined by the columnx, rowy pixel coordinates, width and height. If keepnodata is TRUE, those pixels whose values are NODATA will not be set with the corresponding value in newvalueset. See example Variant 2. + For Variant 3, the specific pixels to be set are determined by the columnx, rowy pixel coordinates, width and height. If keepnodata is TRUE, those pixels whose values are NODATA will not be set with the corresponding value in newvalueset. See example Variant 3. - Variant 3 is the same as Variant 2 with the exception that it assumes that the first band's pixels of rast will be set. + Variant 4 is the same as Variant 3 with the exception that it assumes that the first band's pixels of rast will be set. @@ -4262,6 +4277,99 @@ ORDER BY 1, 2; /* The ST_SetValues() does the following... ++ - + - + - + + - + - + - + +| 1 | 1 | 1 | | 1 | 1 | 1 | ++ - + - + - + + - + - + - + +| 1 | 1 | 1 | => | 1 | 9 | 9 | ++ - + - + - + + - + - + - + +| 1 | 1 | 1 | | 1 | 9 | 9 | ++ - + - + - + + - + - + - + +*/ +SELECT + (poly).x, + (poly).y, + (poly).val +FROM ( +SELECT + ST_PixelAsPolygons( + ST_SetValues( + ST_AddBand( + ST_MakeEmptyRaster(3, 3, 0, 0, 1, -1, 0, 0, 0), + 1, '8BUI', 1, 0 + ), + 1, 1, 1, ARRAY[[-1, -1, -1], [-1, 9, 9], [-1, 9, 9]]::double precision[][], -1 + ) + ) AS poly +) foo +ORDER BY 1, 2; + + x | y | val +---+---+----- + 1 | 1 | 1 + 1 | 2 | 1 + 1 | 3 | 1 + 2 | 1 | 1 + 2 | 2 | 9 + 2 | 3 | 9 + 3 | 1 | 1 + 3 | 2 | 9 + 3 | 3 | 9 + + + +/* +This example is like the previous one. Instead of nosetvalue = -1, nosetvalue = NULL + +The ST_SetValues() does the following... + ++ - + - + - + + - + - + - + +| 1 | 1 | 1 | | 1 | 1 | 1 | ++ - + - + - + + - + - + - + +| 1 | 1 | 1 | => | 1 | 9 | 9 | ++ - + - + - + + - + - + - + +| 1 | 1 | 1 | | 1 | 9 | 9 | ++ - + - + - + + - + - + - + +*/ +SELECT + (poly).x, + (poly).y, + (poly).val +FROM ( +SELECT + ST_PixelAsPolygons( + ST_SetValues( + ST_AddBand( + ST_MakeEmptyRaster(3, 3, 0, 0, 1, -1, 0, 0, 0), + 1, '8BUI', 1, 0 + ), + 1, 1, 1, ARRAY[[NULL, NULL, NULL], [NULL, 9, 9], [NULL, 9, 9]]::double precision[][], NULL::double precision + ) + ) AS poly +) foo +ORDER BY 1, 2; + + x | y | val +---+---+----- + 1 | 1 | 1 + 1 | 2 | 1 + 1 | 3 | 1 + 2 | 1 | 1 + 2 | 2 | 9 + 2 | 3 | 9 + 3 | 1 | 1 + 3 | 2 | 9 + 3 | 3 | 9 + + + + + + Examples: Variant 3 + + +/* +The ST_SetValues() does the following... + + - + - + - + + - + - + - + | 1 | 1 | 1 | | 1 | 1 | 1 | + - + - + - + + - + - + - +