# [postgis-users] MapAlgebra on three Rasters

JamesH james.holmes at newcastle.ac.uk
Wed Apr 25 16:29:41 PDT 2012

```Hi Pierre,

Currently I think I'm close to acheiving this.

Ran successfully this query in PostGIS:
SELECT

ST_MapAlgebraExpr(ST_MapAlgebraExpr((ST_Slope(c.rast,1,'32BF')),1,'32BF','((244-[rast])/244)::float'),1,
ST_MapAlgebraExpr(ST_MapAlgebraExpr(a.rast,1, '32BF',
'((67.6499557495117-[rast])/67.6499557495117)'), 1,
ST_MapAlgebraExpr(b.rast,1, '32BF',
'((14052.134765265-[rast])/14052.134765265)'), 1, '([rast1] * 0.5) +
([rast2] * 0.3)::float', '32BF'),1, '([rast1] * 0.2 + [rast2])::float',
'32BF')
FROM
density a, euclidean b, example_postgis20 c

And I'm now trying to view in OpenJump using:
SELECT ST_AsBinary((gv).geom), (gv).val
FROM (SELECT
ST_DumpAsPolygons(ST_MapAlgebraExpr(ST_MapAlgebraExpr((ST_Slope(c.rast,1,'32BF')),1,'32BF','((244-[rast])/244)::float'),1,
ST_MapAlgebraExpr(ST_MapAlgebraExpr(a.rast,1, '32BF',
'((67.6499557495117-[rast])/67.6499557495117)'), 1,
ST_MapAlgebraExpr(b.rast,1, '32BF',
'((14052.134765265-[rast])/14052.134765265)'), 1, '([rast1] * 0.5) +
([rast2] * 0.3)::float', '32BF'),1, '([rast1] * 0.2 + [rast2])::float',
'32BF')) gv
FROM density a, euclidean b, example_postgis20 c) foo

Its returning as no geometry to it.
Can you see where I'm going wrong with this?
This is one of the last pieces in my dissertation.

Kind Regards,
James

-----