# Why is there a difference between NDVI using Sentinel 2, in ArcMap & QGIS?

I have been trying to calculate the NDVI for a scene using Sentinel 2 bands 4(red) & 8(NIR). I first did it in ArcMap and then QGIS. In both softwares, I used the raster calculator and included the basic NDVI formula = (NIR-Red)/(NIR+Red).

ArcMap gave me a range of 0-9221 (this varies with the stretch applied) while QGIS gave me more plausible values from 0.0258-0.5255.

I have read briefly that Sentinel 2 is TOA reflectance and has a scaling factor of 10000, which apparently can be found in the xml file that gets downloaded with the images. I never found this scaling factor mentioned in the xml file I downloaded.

Why is there this difference? How is the calculation being done on QGIS?

• How sis you calculate the NDVI, with a raster calculator or some tool/plugin? It's obvious something went wrong in the Arcmap calculation, can you edit your post to state exactly how you calculated it? – HDunn Aug 3 '16 at 18:43
• @HDunn- I have included details as you suggested. I did not use any plugins, just the raster calculator in both ArcMap & QGIS. – tg110 Aug 3 '16 at 19:04
• Try forcing Arcmap to treat them as floats, instead of the 8/16bit. to do that, multiply one of the argument by 1.0, note the .0. Something like ((NIR-Red)*1.0)/(NIR+Red). – HDunn Aug 3 '16 at 19:09
• @HDunn- it did work! but the values range in ArcMap -0.75468 to 0.877372 is very different from the range I got using QGIS (0.0258 to 0.5255) Which one is correct? And why is there this difference? – tg110 Aug 3 '16 at 19:15
• Is the stretch similar? try calculating statistics, or try identifying an individual pixel in both programs, it should be the same, or just a precision rounding digit away – HDunn Aug 3 '16 at 19:18

## 2 Answers

Arcmap is notorious for retaining the raster type and not treating values as decimals/float when calculated from 16bit integer rasters.

In order to force Arcmap to treat raster calculation result as a float, you should multiply one of the arguments by 1.0, or simply append a '.0' to a any constant or real number in the formula.

In your case `(NIR-Red)*1.0/(NIR+Red)` will suffice.

• @HDunn- I applied the same stretch and also calculated statistics QGIS- Minimum=-0.684, Maximum=0.817, Mean=0.252, StdDev=0.113 ArcMap- Min= -0.7546, Max= 0.87737, Mean= 0.252, StdDev= 0.113 I mean almost the same. I wonder why the slight difference still. – tg110 Aug 3 '16 at 19:46

Did you check the initial histograms of the respective bands you are using? It is possible that each software are interpreting different no-data values which can skew the results....

• @Alexander- So that is another question I had. The values for the NIR band in QGIS are 527-3234, but in ArcMap it is 0-9212. I don't understand how and why. – tg110 Aug 3 '16 at 20:10
• This could be the source of your issue. When you view the histogram- you will know your no-data value often because it appears at the beginning or end of your histogram- often with a huge number of pixels. What you need to do is a histogram clip - and clip out the no-data values- then re-do your indices and let us know your results :) – Alexander Aug 4 '16 at 0:28
• @Alexander- I do not know how to do a histogram clip. How would I do that? – tg110 Aug 4 '16 at 13:35
• hmmm- I only know how to do it in erdas which is by using the Rescale function. However, did you ever try doing your NDVI without the band calculator in Arcmap? check this link: desktop.arcgis.com/en/arcmap/10.3/manage-data/raster-and-images/… – Alexander Aug 5 '16 at 19:34
• basically, you can rescale the histograms in the image analysis window (often it will exclude no-data by default) - make sure you have the correct bands assigned by going into the image analysis options menu. try your ndvi afterwards and see if it works. – Alexander Aug 5 '16 at 19:35