Member-only story
Functions for 10 Vegetation Indices in Python, Matlab and R Languages
The functions provide the mathematical formulas for 10 common vegetation indices, implemented in Python, Matlab and R languages for data analysis and processing in remote sensing applications.
Previous article: 10 Common Vegetation Indices and Their Applications in Remote Sensing
Here are the functions for the 10 vegetation indices in Python, Matlab, and Python:

Python
1. Normalized Difference Vegetation Index (NDVI):
def ndvi(nir, red):
return (nir - red) / (nir + red)
2. Enhanced Vegetation Index (EVI):
def evi(nir, red, blue):
return 2.5 * (nir - red) / (nir + 6 * red - 7.5 * blue + 1)
3. Soil Adjusted Vegetation Index (SAVI):
def savi(nir, red, L=0.5):
return (nir - red) / (nir + red + L) * (1 + L)
4. Transformed Vegetation Index (TVI):
def tvi(nir, red, green):
return 0.5 * (120 * (nir - green) - 200 * (red - green))
5. Green Normalized Difference Vegetation Index (GNDVI):
def gndvi(nir, green):
return (nir - green) / (nir + green)
6. Modified Soil-Adjusted Vegetation Index (MSAVI):
def msavi(nir, red):
return 0.5 * (2 * nir + 1 - np.sqrt((2 * nir + 1) ** 2 - 8 * (nir - red)))
7. Normalized Difference Infrared Index (NDII):
def ndii(nir, swir):
return (nir - swir) / (nir + swir)
8. Chlorophyll Vegetation Index (CVI):
def cvi(nir, red):
return nir / red - 1