1

This might be a trivial question, but please bear with me. So I am using python and Sentinel images and I want to calculate NDVI, which is (NIR-RED)/(NIR+RED). So in the case where the final result is NAN, this means that this is a zero division right? i.e NIR=-RED? and if NDVI=0 what does this means? because NDVI ranges from (-1) to (1).

0
3

To be fully interpretable, the NDVI has to be computed based on "top-of-canopy" reflectance values. By definition, reflectance values are positive numbers between 0 and 1 (which are often multiplied by a power of 10 for storage issue (better to store 8 or 16 bit integer than float). Therefore, in theory, the only case where you could get an invalid NDVI value with valid reflectance values is when NIR=RED=0 (which is theoretically possible but quite unusual, except maybe a shadow on water with low sensitivity sensor). The NaN in a NDVI image therefore more likely come from missing values (out of the track of the satellite, pixels "removed" by cloud mask...).

One potential issue is that the radiometric correction of the signal relies on many parameters about the atmosphere and are hence not perfect. This could result in (theoretically impossible) negative reflectance values. This is unlikely to occur, but in case it does I would assume that these values should be set to zero befor you compute the NDVI.

As for the NDVI = 0, this is completely valid (but some softwares could interprete the 0 as a background/noData value) and occurs when NIR=RED. With values <= 0 you can safely assume that there is no "green" vegetation (exception: intense yellow or red fower, e.g. rapeseed), while above 0.3 it is most likely that the pixel is covered by some vegetation.

3
  • This actually makes sense now, because I initially calculated NDVI using Sentinel L2A images thinking that these are cloud and cloud shadow-free (I set the max cloud =0.1). Earlier this morning when trying to conduct visual inspection of the true color images, I noticed the presence of clouds and cloud shadows. So this might be the reason for the NAN values right? I also got this error while calculating NDVI and NDWI: RuntimeWarning: invalid value encountered in true_divide ndi = (band_a - band_b + self.acorvi_constant) / (band_a + band_b + self.acorvi_constant) – Rim Sleimi Jun 15 '20 at 20:37
  • Also, how does clouds/cloud shadow appears in the image in terms of pixel value? – Rim Sleimi Jun 15 '20 at 21:08
  • When they were not masked out, cloud and cloud shadows have "valid" reflectance values (very high or very low, respectively), with also valid NDVI values (if the shdow is not "too dark", NDVI can still make sense, it depends on the optical thikness of the cloud). – radouxju Jun 16 '20 at 8:17
1

NDVI=0 is a valid value, but If you got NAN value there is probably pixles that couldn't get a valid value because they were NAN in the beginning (NAN=Not A Number). Anyway when you got NAN that DOES NOT mean it is 0.

1
  • So NAN values cannot be a result of zero division? i.e NIR+RED=Zero?. – Rim Sleimi Jun 15 '20 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.