I am performing a small test to calculate the RBF-kernel NDVI (kNDVI). kNDVI is a nonlinear generalization of the commonly used Normalized Difference Vegetation Index (NDVI). It is a novel spectral index proposed in Camps-Valls et al. 2021.

I am using Sentinel-2 L2A bands 4 (red) and 8 (NIR) without applying any scaling factor. I am trying to calculate the kNDVI using R with the code provided by the authors from their Github.


s2_red <- raster("C:/test_kNDVI/T31SBD_20220808T104631_B04_10m.jp2")
s2_nir <- raster("C:/test_kNDVI/T31SBD_20220808T104631_B08_10m.jp2")

sigma <- 0.15
knr <- exp(-(s2_nir-s2_red)^2/(2*sigma^2))
kndvi <- (1-knr) / (1+knr)

However, when I run the code with (sigma=0.15) I get a strange kNDVI image.

plot(kndvi, main="kNDVI")

enter image description here

What is happening here?


1 Answer 1


It seems you are using Digital Numbers instead of reflectances as specified by the paper. Just divide band values by 10000 before calculating knr.

# get reflectance values

sigma <- 0.15
knr <- exp(-(s2_nir-s2_red)^2/(2*sigma^2))
kndvi <- (1-knr) / (1+knr)
ndvi <- (s2_nir-s2_red)/(s2_nir+s2_red)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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