From: Regina Obe Date: Thu, 17 Feb 2011 13:01:26 +0000 (+0000) Subject: Provide a more useful example of map algebra. X-Git-Tag: 2.0.0alpha1~1960 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=30f00af0a0866aa386220e42bb1d9a5b49248378;p=postgis Provide a more useful example of map algebra. git-svn-id: http://svn.osgeo.org/postgis/trunk@6840 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/doc/reference_raster.xml b/doc/reference_raster.xml index 686cfb300..abe5451a0 100644 --- a/doc/reference_raster.xml +++ b/doc/reference_raster.xml @@ -3374,7 +3374,31 @@ WHERE rid = 2; 250 | 0 254 | 0 254 | 0 - + + Create a new 1 band raster of pixel-type 2BUI from our original that is reclassified. + ALTER TABLE dummy_rast ADD COLUMN map_rast2 raster; +UPDATE dummy_rast SET map_rast2 = ST_MapAlgebra(rast,'CASE WHEN rast + BETWEEN 100 and 250 THEN 1 WHEN rast = 252 THEN 2 WHEN rast BETWEEN 253 and 254 THEN 3 ELSE 0 END', '2BUI') WHERE rid = 2; + +SELECT DISTINCT ST_Value(rast,1,i,j) As origval, ST_Value(map_rast2, 1, i, j) As mapval +FROM dummy_rast CROSS JOIN generate_series(1, 5) AS i CROSS JOIN generate_series(1,5) AS j +WHERE rid = 2; + + origval | mapval +---------+-------- + 249 | 1 + 250 | 1 + 251 | + 252 | 2 + 253 | 3 + 254 | 3 + +SELECT ST_BandPixelType(map_rast2) As b1pixtyp +FROM dummy_rast WHERE rid = 2; + + b1pixtyp +---------- + 2BUI