From: Regina Obe Date: Thu, 17 Feb 2011 06:07:13 +0000 (+0000) Subject: provide an example of map algebra X-Git-Tag: 2.0.0alpha1~1963 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e2b4788c69ec6fb4ad0e73a706c8f5ed516f9c52;p=postgis provide an example of map algebra git-svn-id: http://svn.osgeo.org/postgis/trunk@6837 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/doc/reference_raster.xml b/doc/reference_raster.xml index 6eeb357c0..773af7448 100644 --- a/doc/reference_raster.xml +++ b/doc/reference_raster.xml @@ -3295,7 +3295,7 @@ WHERE A.rid =2 ) As foo; ST_MapAlgebra - Creates a new raster formed by applying algebraic operations defined by the expression on the input raster and of pixeeltype provided. band 1 is assumed if no band is specified. + Creates a new one band raster formed by applying a valid PostgreSQL algebraic operations on the input raster band and of pixeeltype provided. band 1 is assumed if no band is specified. @@ -3345,8 +3345,11 @@ WHERE A.rid =2 ) As foo; Description - Creates a new raster formed by applying algebraic operations defined by the expression on the input raster. If no band number is specified - band 1 is assumed. + Creates a new one band raster formed by applying algebraic operations defined by the expression on the input raster (rast). If no band is specified + band 1 is assumed. The new raster will have the same georeference, width, and height as the original raster but will only have one band. + + If pixeltype is passed in, then the new raster will have a band of that pixeltype. If no pixeltype is passed in, then the new raster band will have the same pixeltype as the input rast + Use the term rast to refer to the band you are changing. Availability: 2.0.0 @@ -3354,12 +3357,31 @@ WHERE A.rid =2 ) As foo; Examples - + Create a new 1 band raster from our original that is a function of modulo 2 of the original raster band. + ALTER TABLE dummy_rast ADD COLUMN map_rast raster; +UPDATE dummy_rast SET map_rast = ST_MapAlgebra(rast,'mod(rast,2)') WHERE rid = 2; + +SELECT ST_Value(rast,1,i,j) As origval, ST_Value(map_rast, 1, i, j) As mapval +FROM dummy_rast CROSS JOIN generate_series(1, 3) AS i CROSS JOIN generate_series(1,3) AS j +WHERE rid = 2; + + origval | mapval +---------+-------- + 253 | 1 + 254 | 0 + 253 | 1 + 253 | 1 + 254 | 0 + 254 | 0 + 250 | 0 + 254 | 0 + 254 | 0 + See Also - + ,