Database Reference
In-Depth Information
FROM stats
ORDER BY state DESC;
The output looks as follows:
state | count | sum | mean | stddev
| min
--------+-------+------------+---------+--------+--------before
| 7081 | 8987349.00 | 1269.22 | 125.87 |
943.00 after | 7081 | 89873.49 | 12.69
| 1.26 | 9.43
In the ST_MapAlgebra() function, we indicate that the output raster's band will
have a pixel type of 32BF and a NODATA value of -9999 . We use the expression
'[rast] / 100.' to convert each pixel value to its true value. Before
ST_MapAlgebra() evaluates the expression, the pixel value replaces the place-
holder '[rast]' . There are several other placeholders available; these can be
found in the ST_MapAlgebra() documentation.
Looking at the summary statistics and comparing the before and after processing,
we see that the map-algebra operation works correctly. So, let's correct the entire
table.Wewillappendthebandcreatedfrom ST_MapAlgebra() totheexistingras-
ter.
UPDATE prism SET rast = ST_AddBand(
rast, ST_MapAlgebra(rast, 1, '32BF', '[rast]
/ 100.', -9999), 1 );
ERROR: new row for relation "prism" violates
check constraint "enforce_out_db_rast"
The SQL query will not work. Why? If you remember, when we loaded the PRISM
rasters, we instructed raster2pgsql to add the standard constraints with the -C
flag. It looks as if we violated at least one of those constraints.
When installed, the standard constraints enforce a set of rules on each value of a
rastercolumninthetable.Theserulesguaranteethateachrastercolumnvaluehas
Search WWH ::




Custom Search