[GRASSLIST:2358] Re: NDVI...why i get an all 0 raster file?
Eric G. Miller
egm2 at jps.net
Mon Aug 20 00:09:10 EDT 2001
On Sun, Aug 19, 2001 at 09:16:36PM -0600, Luis Coronado wrote:
> Hi there people!.
> Im trying to add several ratio bands to my ETM+ data set of the north
> region of Costa Rica. I calculated all the ETM+#/ETM+# with
> mapcalculator.sh and r.mapcalc, and both work fine. But, when trying to
> obtain the NDVI, the result was a raster file full of 0's.
> I now that this isnt the result because i also did the same with IDRISI.
>
> Any tip here?
> -*-*-*-*-*-*-*-*
> NDVI=(BAND4-BAND3)/(BAND4+BAND3)
> *-*-*-*-*-*-*-*-
You're seeing the result of integer division. Cast the division to a
float, multiply by 100 and cast it back to an int. It's a percentage,
so you want a result between 0-100 (no?). You could leave out the
multiplication and the round(), but you'll have really small cell values
[0,1].
ndvi = round( 100 * ((float (band4 - band3)) / (band4 + band3)))
--
Eric G. Miller <egm2 at jps.net>
More information about the grass-user
mailing list