Raster Calculator

4031
10
07-23-2012 11:27 PM
WersusBarckowich
New Contributor
Hello!
I try to calculate NDVI using Raster Calculator:

But result has only three values (and three colors): -1, 0 and +1.
What am I doing wrong?
Thanks!
0 Kudos
10 Replies
SheaMeyer
New Contributor II
You must first convert your .TIF bands from an integer to a float.

The integer using an 8 bit pixel type for DN values from 0 - 255 in whole numbers.

The float (32 bit) allows for decimals.

The map algebra is Float ("%file.tif%")
0 Kudos
WersusBarckowich
New Contributor
Thanks!
But how can I do this?
0 Kudos
SheaMeyer
New Contributor II
Use the same exact NDVI equation in raster calculator as you have now, but instead of the band 3 and band 4 .tif you are currently using from landsat, replace them with the output after converting them to a float.

You can convert them in raster calculator with the expression i.e. Float ("%Band 3.tif%") and repeat for band 4.
Or you can use the Float tool in the toolbox Spatial Analyst -> Math.
I recommend converting them to GRID files as well when converting to the float. Simply enough, just don't add the .tif extension when you name the output raster.

Good luck.
0 Kudos
WersusBarckowich
New Contributor
I try to add "%L5015041_04120090613_B30.TIF%" in raster calc, but I have error:

Executing: RasterCalculator "%L5015041_04120090613_B30.TIF%" C:\Users\Admin\Documents\ArcGIS\Default.gdb\rastercalc2
Start Time: Tue Jul 24 21:27:02 2012
"%L5015041_04120090613_B30.TIF%"
ERROR 000539: Error running expression: rcexec() <type 'exceptions.AttributeError'>: 'str' object has no attribute 'save'
Failed to execute (RasterCalculator).
Failed at Tue Jul 24 21:27:02 2012 (Elapsed Time: 0,00 seconds)
0 Kudos
SheaMeyer
New Contributor II
Try to calculate statistics for the .tif file. Might be why it can't find a "table."
0 Kudos
SheaMeyer
New Contributor II
Try to calculate statistics for the .tif file. Might be why it can't find a "table."


*Attribute I mean not table
0 Kudos
AnnetteWielemaker
New Contributor
Have you tried:
Float(Float("L5015041_04120090613_B40.TIF" - "L5015041_04120090613_B30.TIF") / Float("L5015041_04120090613_B40.TIF" + "L5015041_04120090613_B30.TIF"))
??
0 Kudos
PeterHarrel
New Contributor
We do this all the time in our GIS class.  If you input image bands are integer, ArcGIS will default to an output of Integer.  Since NDVI has a range of -1 to +1, you end up with only -1,0, +1.  To fix this, simply multiply one of the layers in the equation by 1.0, with the decimal. ArcGIS then defualts to float for the output.
0 Kudos
JeffreySwain
Esri Regular Contributor
If you are using version 10 or higher, you can also create the NDVI output with the mosaic dataset as well.
0 Kudos