Indices

Normalized Difference Vegetation Index (NDVI)¤

Compute the Normalized Difference Vegetation Index (NDVI) from red and near-infrared (NIR) raster bands for a time series of GeoTIFF files. The function scans the input directory recursively for .tif files, groups them by acquisition date (parsed from the filename), and computes NDVI for each date using the specified red and NIR band numbers. Output NDVI rasters are written as float32 GeoTIFFs to the output directory.

NDVI is calculated as:

NDVI = (NIR - RED) / (NIR + RED)

Division-by-zero is handled by assigning the specified nodata value.

Parameters¤

Name Type Description
input_dir str Specify the directory containing the satellite images. This directory can have a hierarchical structure with GeoTIFF files.
output_dir str The output directory is where the masked images will be stored. The output structure is flat.
band_red int, str Band number corresponding to the red band. The band is identified in filenames by matching either b01, b1 or b1A.
band_nir int, str Band number corresponding to the near-infrared (NIR) band. The band is identified in filenames by matching either b01, b1 or b1A
nodata int NoData value to assign where NDVI cannot be computed (e.g., division by zero, background). Default is -9999.

Example¤

Python
from sipt.processing import ndvi

ndvi("./src", "./processed", 4, 5)