Database Reference
In-Depth Information
How to do it...
With any operation that is going to take a while and/or modify a stored raster, it is
besttotestthatoperationtoensuretherearenomistakesandtheoutputlookscor-
rect.
Let's run ST_MapAlgebra() (or ST_MapAlgebraExpr() if you are running
PostGIS2.0)ononerastertileandcomparethesummarystatisticsbeforeandafter
the map-algebra operation.
WITH stats AS (
SELECT
'before' AS state,
(ST_SummaryStats(rast, 1)).*
FROM prism
WHERE rid = 550
UNION ALL
SELECT
'after' AS state, (
ST_SummaryStats(
ST_MapAlgebra(rast, 1, '32BF', '
[rast] / 100.', -9999),
1
)
).*
FROM prism
WHERE rid = 550
)
SELECT
state,
count,
round(sum::numeric, 2) AS sum,
round(mean::numeric, 2) AS mean,
round(stddev::numeric, 2) AS stddev,
round(min::numeric, 2) AS min,
round(max::numeric, 2) AS max
Search WWH ::




Custom Search