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

Pierre Racine Pierre.Racine at sbf.ulaval.ca
Mon Mar 26 08:42:47 PDT 2012


> > 5) What is the result of:SELECT PostGIS_Full_Version();
> "POSTGIS="2.0.0SVN" GEOS="3.3.2dev-CAPI-1.7.2" PROJ="Rel. 4.6.1, 21 August
> 2008" GDAL="GDAL 1.9dev, released 2011/01/18" LIBXML="2.7.8" USE_STATS"
> 
> >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;
> 
> Attempted and returns: "Neither raster provided has a NODATA value for the
> specified band indices.  NODATA value set to minimum possible for 8BUI"
> 
> ERROR:  syntax error at or near "["
> LINE 1: SELECT (([$1] - [$2]) / ([$1] + [$2])::FLOAT)::double precis...
>                  ^
> QUERY:  SELECT (([$1] - [$2]) / ([$1] + [$2])::FLOAT)::double precision

You don't have a recent version (we are at beta 4), so try this instead (just remove the braquets):

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