[postgis-users] NDVI Calculation from two bands within one Raster

Pierre Racine Pierre.Racine at sbf.ulaval.ca
Tue Apr 3 13:02:16 PDT 2012


> SELECT
> 	ST_MapAlgebraExpr(a.rast, 4, b.rast, 3, '(a.rast - b.rast) /(a.rast +
> b.rast)::float')
> FROM
> 	nclraster1 a, nclraster1 b;
> 
> instead of rast1 - rast2 etc.
> 
> Returns an error of
> ERROR:  missing FROM-clause entry for table "a"
> LINE 1: SELECT ((a.rast - b.rast) /(a.rast + b.rast)::float)::double...
> 
> Can anyone explain this?

In the expression, you don't refer to the pixels of a.rast with "a.rast" but with "rast1". so your query should be:

SELECT 	ST_MapAlgebraExpr(a.rast, 4, b.rast, 3, '(rast1 - rast2) /(rast1 + rast2)::float') FROM nclraster1 a, nclraster1 b;

Pierre



More information about the postgis-users mailing list