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

Pierre Racine Pierre.Racine at sbf.ulaval.ca
Mon Mar 26 08:16:46 PDT 2012


> SELECT
> 	ST_MapAlgebra(ST_MapAlgebra(a.rast, 4, b.rast, 3, "rast - b.rast",
> "8BUI"), ST_MapAlgebra(a.rast, 4, b.rast, 3, "a.rast + b.rast2", "8BUI"), "a.rast /
> b.rast", "8BUI") FROM
> 	nclraster1 a, nclraster1 b;
> 
> This does not work for me, returning the column a.rast does not exist.

1) Do you have a column of type "raster" in table "nclraster1"?

2) Is it named "rast"?

3) Is this raster tiled? (or Do you have more than one row in "nclraster1"?)

4) What if the results of 

SELECT (ST_SummaryStats(rast)).*
FROM nclraster1

?

5) What is the result of:

SELECT PostGIS_Full_Version();

6) Your query should probably more look like (if you have a recent version of PostGIS):

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