]> granicus.if.org Git - postgis/commitdiff
Provide a more useful example of map algebra.
authorRegina Obe <lr@pcorp.us>
Thu, 17 Feb 2011 13:01:26 +0000 (13:01 +0000)
committerRegina Obe <lr@pcorp.us>
Thu, 17 Feb 2011 13:01:26 +0000 (13:01 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@6840 b70326c6-7e19-0410-871a-916f4a2858ee

doc/reference_raster.xml

index 686cfb300d3a437019127c28281bb2cc5419145b..abe5451a08048491d7da27dbe6918b34fcae5d4d 100644 (file)
@@ -3374,7 +3374,31 @@ WHERE rid = 2;
      250 |      0
      254 |      0
      254 |      0
-                               </programlisting>                               
+                               </programlisting>
+                               <para>Create a new 1 band raster of pixel-type 2BUI from our original that is reclassified.</para>
+                               <programlisting>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</programlisting>                         
                        </refsection>
 
                        <refsection>