[postgis-users] NDVI Calculation from two bands within one Raster
Pierre Racine
Pierre.Racine at sbf.ulaval.ca
Mon Mar 26 09:06:49 PDT 2012
> Attempted
> SELECT ST_MapAlgebraExpr(a.rast, 4, b.rast, 3, '(rast1 - rast2) /(rast1 +
> rast2)::float') FROM nclraster1 a, nclraster1 b;
>
> Returned "Neither raster provided has a NODATA value for the specified band
> indices. NODATA value set to minimum possible for 8BUI"
>
> Updated NoDataValues for bands 3 and 4 to 255 (were previously blank) and
> when re-ran, returns:
> "ERROR: division by zero
> CONTEXT: SQL statement "SELECT (($1 - $2) /($1 + $2)::FLOAT)::double
> precision"
Then you must have some 0s in band 3? What is the result of
SELECT ST_ValueCount(rast, 3, 0.0)
FROM nclraster1
What do you want/expect as result when band 3 = 0?
More information about the postgis-users
mailing list