Divide raster by raster

4449
5
03-26-2011 02:04 PM
DavidSmith4
New Contributor
Hi everybody,

Sorry for my basic knowledge in the GIS world. I have problems in dividing raster layer by raster. I have two raster layers (say layer A and B). Both layers have the same extent, projection, pixel size and pixel numbers. AND both have input integer. Value of layer A is always greater than value of layer B (in corresponding pixel). I tried to divide A by B and multiply by 100 using raster calculator in ArcGIS 9.2. The problem is here. I always get 0 and 100 (only two values) . In fact, I expected to have many values ranging from 0 to 100. 

Thank you very much in advance.
0 Kudos
5 Replies
DanPatterson_Retired
MVP Emeritus
You are encountering integer division (read all about it).  To overcome this you need to cast one of the two grids to its floating point representation.  In version 10, this would be accomplished by using "float" either the tool or within the raster calculator.
0 Kudos
NathanJennings
New Contributor III
I have run into this same problem in ArcGIS 10, SP2.  This process works in ArcGIS 10, Windows XP, but does not seem to work on ArcGIS 10, SP2, Windows 7, 32-bit.

Within a Raster Calculator tool I have Float (Band 4 - Band 3) / Float (Band 4 + Band 3).  This is NDVI.  Yes, I know there is an NDVI tool in the Image Analyst Window.

I can create a Python script with the NDVI sytnax and the process works correctly, however, within the ArcToolbox, Raster Calculator, I am returned with a single value.  Even if I add a scaling factor such as:  (Float (Band 4 - Band 3) / Float (Band 4 + Band 3) * 100) + 100.  I still receive a single value for all of my pixels.  This is telling me that there is something going wrong with the Raster calculator.  The output is a 32 bit floating point data type. I have tried GRID, Imagine format, and TIF.  Even if you do a simple division between Float(Band 4) / Float(Band 3), this is still a problem.

I believe this is a bug or may be related to the Windows OS, but I have not found anyone who has solved this issue on Windows 7, 32-bit OS.  I ran into a similar issue with running the ISO cluster routine.  Here is this post and my sample image that you can try on this post:  http://forums.arcgis.com/threads/23726-iso-cluster-unsupervised-classification-ArcGIS-10-Windows-XP

Any insight would be appreciated, otherwise, I will probably put in a trouble ticket with ESRI.

Thank you,
Nate
0 Kudos
DanPatterson_Retired
MVP Emeritus
Just curious ... are these ESRI grids in a folder (ie c:\stuff) or in a gdb?
0 Kudos
NathanJennings
New Contributor III
No, the image is a subset of a Landsat image in Imagine format that is in a folder (c:\temp, for example).  The link I posted just a few minutes ago has a zip file that contains this image if you want to take a look.  6 bands in the image, unsigned integer values.
0 Kudos
NathanJennings
New Contributor III
No, the image is a subset of a Landsat image in Imagine format that is in a folder (c:\temp, for example).  The link I posted just a few minutes ago has a zip file that contains this image if you want to take a look.  6 bands in the image, unsigned integer values.


ESRI Confirmed my issue as a bug: 

[#NIM073015  Raster calculator is giving incorrect output when dividing two image bands as floating point. ]

This bug will now be reviewed by our development team, and will take further action as necessary to address this issue. For updates on this issue, please see the Esri Customer Care Portal by going to https://customers.esri.com or contact Esri Support Services.

Cheers,
Nate
0 Kudos