# ENVI band math incorrect values

I'm attempting to calculate vegetation indices in ENVI 5.2 using level-2 AVIRIS data in band math.

The indices I'm working with are Vogelmann Red Edge 2, normalized difference red edge, and red edge NDVI (reNDVI). All these indices have the same format as for NDVI.

In band math I am using: `float(B1-B2)/float(B1+B2)`

These indices are supposed to all be in the range of -1 to 1, however they are typically outside of the -1 to 1 range.

For example, I tested this band math equation for NDVI and got a range of -1.163 to 0.946.

I've tried other iterations of the band math equation (e.g., altering which variables are designated "float"), but they also produce indices that are outside of the valid range.

What am I doing wrong?

EDIT:

Re-doing the indices in ENVI, most values are in the proper range. The table below is for reNDVI using `(float(b1)-float(b2))/(float(b1)+float(b2))`. The second column, "count" indicates there are almost 19 million pixels with a value near -0.24, with another 10 million pixels in the two bins next to it. However, a couple hundred pixels are still out of range. I'm not sure why I get this. Does this make the whole band invalid (for the index), or are these really low values to be expected from things like bad pixels? • Which tools are you using to calculate the indices? – Aaron Mar 22 '18 at 20:26
• I'm using band math. – user5858 Mar 22 '18 at 20:27
• Try the following syntax: `(float(b1)-float(b2))/(float(b1)+float(b2))` – Aaron Mar 22 '18 at 20:34
• I got the same answer. However, when I imported the band into ArcMap I couldn't find pixels <-1, and by using the identify tool all the pixels seem to be in the valid range. Could this just be an artifact of how ENVI band math works? – user5858 Mar 22 '18 at 20:50
• What is the NoData value? – Aaron Mar 22 '18 at 20:51

## 2 Answers

pay attention that, before spectral index, atmospheric correction must be done. it would be better if you rescaled your corrected values (surface reflectance) between 0 and 1 using below equation:

``````(b1 le 0) * 0 +(b1 gt 10000) * 1 + (b1 gt 0 and b1 le 10000) * float(b1/10000.0)
``````

after atmospheric correction and rescaling, compute your indices.

It is likely that the bad values are actually artifacts near the edge of the image, where some spectral bands may have information while others do not. That type of error can result in various values outside of the expected range.
In order to fix that issue, you can create a mask file which requires that all bands have values within the expected range of values from your band.