darts_preprocessing.engineering.indices
¶
Calculation of spectral indices from optical data.
calculate_ctvi
¶
Calculate CTVI (Corrected Transformed Vegetation Index) from spectral bands.
CTVI is a corrected version of TVI that maintains the sign of the original NDVI values while applying the transformation.
Parameters:
-
optical(xarray.Dataset) –Dataset containing: - ndvi (float32): NDVI values (will be calculated if not present) - nir, red (float32): Required if NDVI not present
Returns:
Note
Formula: CTVI = (NDVI + 0.5) / |NDVI + 0.5| * sqrt(|NDVI + 0.5|)
If NDVI is already in the dataset, it will be reused to avoid recalculation.
References
Lemenkova, Polina. "Hyperspectral Vegetation Indices Calculated by Qgis Using Landsat Tm Image: a Case Study of Northern Iceland" Advanced Research in Life Sciences, vol. 4, no. 1, Sciendo, 2020, pp. 70-78. https://doi.org/10.2478/arls-2020-0021
Source code in darts-preprocessing/src/darts_preprocessing/engineering/indices.py
calculate_evi
¶
calculate_evi(
optical: xarray.Dataset,
g: float = 2.5,
c1: float = 6,
c2: float = 7.5,
l: float = 1,
) -> xarray.DataArray
Calculate EVI (Enhanced Vegetation Index) from spectral bands.
EVI is optimized to enhance vegetation signal with improved sensitivity in high biomass regions and improved vegetation monitoring through decoupling of canopy background signal and reducing atmospheric influences.
Parameters:
-
optical(xarray.Dataset) –Dataset containing spectral bands: - nir (float32): Near-infrared reflectance [0-1] - red (float32): Red reflectance [0-1] - blue (float32): Blue reflectance [0-1]
-
g(float, default:2.5) –Gain factor. Defaults to 2.5.
-
c1(float, default:6) –Aerosol resistance coefficient for red band. Defaults to 6.
-
c2(float, default:7.5) –Aerosol resistance coefficient for blue band. Defaults to 7.5.
-
l(float, default:1) –Canopy background adjustment. Defaults to 1.
Returns:
Note
Formula: EVI = G * (NIR - Red) / (NIR + C1 * Red - C2 * Blue + L)
Input bands are clipped to [0, 1] to avoid numerical instabilities.
References
A Huete, K Didan, T Miura, E.P Rodriguez, X Gao, L.G Ferreira, Overview of the radiometric and biophysical performance of the MODIS vegetation indices, Remote Sensing of Environment, Volume 83, Issues 1-2, 2002, Pages 195-213, ISSN 0034-4257, https://doi.org/10.1016/S0034-4257(02)00096-2.
Source code in darts-preprocessing/src/darts_preprocessing/engineering/indices.py
calculate_exg
¶
Calculate EXG (Excess Green Index) from spectral bands.
EXG highlights green vegetation by emphasizing the green band relative to red and blue. Widely used for crop/weed discrimination and precision agriculture.
Parameters:
-
optical(xarray.Dataset) –Dataset containing spectral bands: - green (float32): Green reflectance [0-1] - red (float32): Red reflectance [0-1] - blue (float32): Blue reflectance [0-1]
Returns:
Note
Formula: EXG = 2 * Green - Red - Blue
Input bands are clipped to [0, 1] to avoid numerical instabilities.
References
Upendar, K., Agrawal, K.N., Chandel, N.S. et al. Greenness identification using visible spectral colour indices for site specific weed management. Plant Physiol. Rep. 26, 179-187 (2021). https://doi.org/10.1007/s40502-020-00562-0
Example
Source code in darts-preprocessing/src/darts_preprocessing/engineering/indices.py
calculate_gli
¶
Calculate GLI (Green Leaf Index) from spectral bands.
GLI emphasizes green reflectance for vegetation detection using only visible bands. Suitable for RGB sensors and aerial imagery.
Parameters:
-
optical(xarray.Dataset) –Dataset containing spectral bands: - green (float32): Green reflectance - red (float32): Red reflectance - blue (float32): Blue reflectance
Returns:
Note
Formula: GLI = (2 * Green - Red - Blue) / (2 * Green + Red + Blue)
References
Eng, L.S., Ismail, R., Hashim, W., Baharum, A., 2019. The Use of VARI, GLI, and VIgreen Formulas in Detecting Vegetation In aerial Images. International Journal of Technology. Volume 10(7), pp. 1385-1394 https://doi.org/10.14716/ijtech.v10i7.3275
Source code in darts-preprocessing/src/darts_preprocessing/engineering/indices.py
calculate_gndvi
¶
Calculate GNDVI (Green Normalized Difference Vegetation Index) from spectral bands.
GNDVI is similar to NDVI but uses the green band instead of red, making it more sensitive to chlorophyll content and useful for mid to late season vegetation monitoring.
Parameters:
-
optical(xarray.Dataset) –Dataset containing spectral bands: - nir (float32): Near-infrared reflectance [0-1] - green (float32): Green reflectance [0-1]
Returns:
-
xarray.DataArray–xr.DataArray: GNDVI values with attributes: - long_name: "GNDVI" - Values clipped to [-1, 1] range
Note
Formula: GNDVI = (NIR - Green) / (NIR + Green)
Input bands are clipped to [0, 1] to avoid numerical instabilities.
Source code in darts-preprocessing/src/darts_preprocessing/engineering/indices.py
calculate_grvi
¶
Calculate GRVI (Green Red Vegetation Index) from spectral bands.
GRVI uses visible bands to detect vegetation, useful for high-resolution imagery where NIR may not be available or for specific vegetation discrimination tasks.
Parameters:
-
optical(xarray.Dataset) –Dataset containing spectral bands: - green (float32): Green reflectance [0-1] - red (float32): Red reflectance [0-1]
Returns:
Note
Formula: GRVI = (Green - Red) / (Green + Red)
Input bands are clipped to [0, 1] to avoid numerical instabilities.
References
Eng, L.S., Ismail, R., Hashim, W., Baharum, A., 2019. The Use of VARI, GLI, and VIgreen Formulas in Detecting Vegetation In aerial Images. International Journal of Technology. Volume 10(7), pp. 1385-1394 https://doi.org/10.14716/ijtech.v10i7.3275
Source code in darts-preprocessing/src/darts_preprocessing/engineering/indices.py
calculate_ndvi
¶
Calculate NDVI (Normalized Difference Vegetation Index) from spectral bands.
NDVI is a widely-used vegetation index that indicates photosynthetic activity and vegetation health. Values range from -1 to 1, with higher values indicating denser, healthier vegetation.
Parameters:
-
optical(xarray.Dataset) –Dataset containing spectral bands: - nir (float32): Near-infrared reflectance [0-1] - red (float32): Red reflectance [0-1]
Returns:
Note
Formula: NDVI = (NIR - Red) / (NIR + Red)
Input bands are clipped to [0, 1] before calculation to avoid numerical instabilities from negative reflectance values or sensor artifacts. The final result is also clipped to ensure values remain in the valid [-1, 1] range.
Example
Calculate NDVI from optical data:
Source code in darts-preprocessing/src/darts_preprocessing/engineering/indices.py
calculate_nrvi
¶
Calculate NRVI (Normalized Ratio Vegetation Index) from spectral bands.
NRVI normalizes RVI to a range similar to NDVI, making it more comparable across different vegetation densities.
Parameters:
-
optical(xarray.Dataset) –Dataset containing: - rvi (float32): RVI values (will be calculated if not present) - nir, red (float32): Required if RVI not present
Returns:
Note
Formula: NRVI = (RVI - 1) / (RVI + 1) where RVI = Red / NIR
If RVI is already in the dataset, it will be reused to avoid recalculation.
Source code in darts-preprocessing/src/darts_preprocessing/engineering/indices.py
calculate_rvi
¶
Calculate RVI (Ratio Vegetation Index) from spectral bands.
RVI is a simple ratio index sensitive to vegetation amount and biomass. Values typically range from 0 to over 30 for dense vegetation.
Parameters:
-
optical(xarray.Dataset) –Dataset containing spectral bands: - nir (float32): Near-infrared reflectance [0-1] - red (float32): Red reflectance [0-1]
Returns:
Note
Formula: RVI = Red / NIR
Input bands are clipped to [0, 1] to avoid numerical instabilities.
References
Lemenkova, Polina. "Hyperspectral Vegetation Indices Calculated by Qgis Using Landsat Tm Image: a Case Study of Northern Iceland" Advanced Research in Life Sciences, vol. 4, no. 1, Sciendo, 2020, pp. 70-78. https://doi.org/10.2478/arls-2020-0021
Source code in darts-preprocessing/src/darts_preprocessing/engineering/indices.py
calculate_savi
¶
Calculate SAVI (Soil Adjusted Vegetation Index) from spectral bands.
SAVI minimizes soil brightness influences using a soil-brightness correction factor. Useful in areas with sparse vegetation or exposed soil.
Parameters:
-
optical(xarray.Dataset) –Dataset containing: - ndvi (float32): NDVI values (will be calculated if not present) - nir, red (float32): Required if NDVI not present
-
s(float, default:0.5) –Soil adjustment factor. Common values: - 0.5: moderate vegetation cover (default) - 0.25: high vegetation cover - 1.0: low vegetation cover
Returns:
Note
Formula: SAVI = NDVI * (1 + s)
References
Lemenkova, Polina. "Hyperspectral Vegetation Indices Calculated by Qgis Using Landsat Tm Image: a Case Study of Northern Iceland" Advanced Research in Life Sciences, vol. 4, no. 1, Sciendo, 2020, pp. 70-78. https://doi.org/10.2478/arls-2020-0021
Example
Source code in darts-preprocessing/src/darts_preprocessing/engineering/indices.py
calculate_tgi
¶
Calculate TGI (Triangular Greenness Index) from spectral bands.
TGI is sensitive to chlorophyll content and can estimate leaf area index without calibration. Particularly useful for crop monitoring.
Parameters:
-
optical(xarray.Dataset) –Dataset containing spectral bands: - red (float32): Red reflectance [0-1] - green (float32): Green reflectance [0-1] - blue (float32): Blue reflectance [0-1]
Returns:
Note
Formula: TGI = -0.5 * [190 * (Red - Green) - 120 * (Red - Blue)]
Input bands are clipped to [0, 1] to avoid numerical instabilities.
References
E. Raymond Hunt, Paul C. Doraiswamy, James E. McMurtrey, Craig S.T. Daughtry, Eileen M. Perry, Bakhyt Akhmedov, A visible band index for remote sensing leaf chlorophyll content at the canopy scale, International Journal of Applied Earth Observation and Geoinformation, Volume 21, 2013, Pages 103-112, ISSN 1569-8432, https://doi.org/10.1016/j.jag.2012.07.020.
Source code in darts-preprocessing/src/darts_preprocessing/engineering/indices.py
calculate_ttvi
¶
Calculate TTVI (Thiam's Transformed Vegetation Index) from spectral bands.
TTVI applies an absolute value transformation to NDVI before the square root, making it suitable for both positive and negative NDVI values.
Parameters:
-
optical(xarray.Dataset) –Dataset containing: - ndvi (float32): NDVI values (will be calculated if not present) - nir, red (float32): Required if NDVI not present
Returns:
Note
Formula: TTVI = sqrt(|NDVI| + 0.5)
If NDVI is already in the dataset, it will be reused to avoid recalculation.
References
Lemenkova, Polina. "Hyperspectral Vegetation Indices Calculated by Qgis Using Landsat Tm Image: a Case Study of Northern Iceland" Advanced Research in Life Sciences, vol. 4, no. 1, Sciendo, 2020, pp. 70-78. https://doi.org/10.2478/arls-2020-0021
Source code in darts-preprocessing/src/darts_preprocessing/engineering/indices.py
calculate_tvi
¶
Calculate TVI (Transformed Vegetation Index) from spectral bands.
TVI applies a transformation to NDVI to enhance contrast and improve discrimination of vegetation conditions.
Parameters:
-
optical(xarray.Dataset) –Dataset containing: - ndvi (float32): NDVI values (will be calculated if not present) - nir, red (float32): Required if NDVI not present
Returns:
Note
Formula: TVI = sqrt(NDVI + 0.5)
If NDVI is already in the dataset, it will be reused to avoid recalculation.
References
Lemenkova, Polina. "Hyperspectral Vegetation Indices Calculated by Qgis Using Landsat Tm Image: a Case Study of Northern Iceland" Advanced Research in Life Sciences, vol. 4, no. 1, Sciendo, 2020, pp. 70-78. https://doi.org/10.2478/arls-2020-0021
Source code in darts-preprocessing/src/darts_preprocessing/engineering/indices.py
calculate_vari
¶
Calculate VARI (Visible Atmospherically Resistant Index) from spectral bands.
VARI uses only visible bands, designed to minimize atmospheric effects. Useful for RGB imagery without NIR band or for atmospheric correction validation.
Parameters:
-
optical(xarray.Dataset) –Dataset containing spectral bands: - green (float32): Green reflectance [0-1] - red (float32): Red reflectance [0-1] - blue (float32): Blue reflectance [0-1]
Returns:
Note
Formula: VARI = (Green - Red) / (Green + Red - Blue)
Input bands are clipped to [0, 1] to avoid numerical instabilities.
References
Eng, L.S., Ismail, R., Hashim, W., Baharum, A., 2019. The Use of VARI, GLI, and VIgreen Formulas in Detecting Vegetation In aerial Images. International Journal of Technology. Volume 10(7), pp. 1385-1394 https://doi.org/10.14716/ijtech.v10i7.3275
Source code in darts-preprocessing/src/darts_preprocessing/engineering/indices.py
calculate_vdvi
¶
Alias for GLI (Green Leaf Index) from an xarray Dataset containing spectral bands.
Source code in darts-preprocessing/src/darts_preprocessing/engineering/indices.py
calculate_vigreen
¶
Alias for VIGREEN (Vegetation Index Green) from an xarray Dataset containing spectral bands.