Skip to content
This repository has been archived by the owner on Jun 18, 2023. It is now read-only.

Function for NDVI #106

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions yatsm/vegetation_indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,27 @@ def EVI(red, nir, blue):

"""
return 2.5 * (nir - red) / (nir + 6 * red - 7.5 * blue + 1)

def NDVI(red, nir):
""" Return the Normalized Difference Vegetation Index for a set of np.ndarrays

NDVI is calculated as:

.. math::
\\frac{(NIR - RED)}{(NIR + RED )}

where:
- :math:`RED` is the red band
- :math:`NIR` is the near infrared band

Note: bands must be given in float datatype from [0, 1]

Args:
red (np.ndarray): red band
nir (np.ndarray): NIR band

Returns:
np.ndarray: NDVI

"""
return (nir - red) / (nir + red)