eodal.core.spectral_indices module

This module contains a set of commonly used Spectral Indices (VIs). The formula are generic by using color names. Thus, they can be applied to different remote sensing platforms and are not bound to a predefined band selection.

Copyright (C) 2022 Lukas Valentin Graf

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

class eodal.core.spectral_indices.SpectralIndices(band_mapping: Dict[str, str] | None = {})[source]

Bases: object

generic spectral indices

BSI(collection)[source]

Calculates the Bare Soil Index (BSI).

Parameters:

collection – reflectance in the ‘blue’, ‘red’, ‘nir_1’ and ‘swir_1’ channel

Returns:

BSI values

CI_GREEN(collection) array[source]

Calculates the green chlorophyll index (CI_green). It is sensitive to canopy chlorophyll concentration (CCC).

Parameters:

collection – reflectance in the ‘green’ and ‘nir_1’ channel

Returns:

CI-green values

CR(collection)[source]

Calculates the Cross Ratio VH/VV

EVI(collection)[source]

Calculates the Enhanced Vegetation Index (EVI) following the formula provided by Huete et al. (2002)

Parameters:

collection – reflectance in the ‘blue’, ‘red’ and ‘nir_1’ channel

Returns:

EVI values

GNDVI(collection)[source]

Calculates the Green Normalized Difference Vegetation Index :param collection:

reflectance in the ‘nir_1’ and ‘green’ channel

Returns:

GNDVI values

MCARI(collection)[source]

Calculates the Modified Chlorophyll Absorption Ratio Index (MCARI). It is sensitive to leaf chlorophyll concentration (LCC).

Parameters:

collection – refletcnace in the ‘green’, ‘red’, and ‘red_edge_1’ channel

Returns:

MCARI values

MSAVI(collection) array[source]

Calculates the Modified Soil-Adjusted Vegetation Index (MSAVI). MSAVI is sensitive to the green leaf area index (greenLAI).

Parameters:

collection – reflectance in the ‘red’ and ‘nir_1’ channel

Returns:

MSAVI values

MTCARI_OSAVI(collection) array[source]

Calculates the ratio of the Transformed Chlorophyll Index (TCARI) and the Optimized Soil-Adjusted Vegetation Index (OSAVI). It is sensitive to changes in the leaf chlorophyll content (LCC).

Parameters:

collection – reflectance in the ‘green’, ‘red’, ‘red_edge_1’, ‘red_edge_3’ channel

Returns:

TCARI/OSAVI values

NDRE(collection) array[source]

Calculates the Normalized Difference Red Edge (NDRE). It extends the capabilities of the NDVI for middle and late season crops.

Parameters:

collection – reflectance in the ‘red_edge_1’ and ‘red_edge_3’ channel

Returns:

NDRE values

NDRI(collection)[source]

Calculates the Normalized Difference Residue Index. Useful for detecting crop residues.

Parameters:

collection – reflectance in the ‘red’ and ‘swir_2’ channel

Returns:

NDRI values

NDTI(collection)[source]

Calculates the Normalized Tillage Index. Useful for tillage and crop residues. :param collection:

reflectance in the ‘swir_1’ and ‘swir_2’ channel

Returns:

NDTI values

NDVI(collection) array[source]

Calculates the Normalized Difference Vegetation Index (NDVI) using the red and the near-infrared (NIR) channel.

Parameters:

collection – reflectance in the ‘red’ and ‘nir_1’ channel

Returns:

NDVI values

NDWI(collection)[source]

Calculates the Normalized Difference Yellowness Index

Parameters:

collection – reflectance in the ‘green’ and ‘nir channel

Returns:

NDYI values

NDYI(collection)[source]

Calculates the Normalized Difference Yellowness Index

Parameters:

collection – reflectance in the ‘blue’, ‘green’, channel

Returns:

NDYI values

NHI(collection)[source]

Calculates the Normalized Humidity Index. First described for detecting ponds with vegetation in and on top. :param collection:

reflectance in the ‘green’ and ‘swir_1’ channel

Returns:

NHI values

VARI(collection)[source]

Calculates the Visible Atmospherically Resistant Index (VARI)

Parameters:

collection – reflectance in the ‘blue’, ‘red’, ‘nir_1’ and ‘swir_1’ channel

Returns:

BSI values

__init__(band_mapping: Dict[str, str] | None = {})[source]

Class constructor. To override the default bands pass custom band mappings as a dictionary:

Example

To use Sentinel-2 band nir_2 (Band 8A) instead of Sentinel-2 band nir_1 (Band 8) for, e.g., NDVI calculation pass

# use nir_2 instead of nir_1
# the other bands remain unaffected
band_mapping = {'nir_1': 'nir_2'}
spectral_indices = SpectralIndices(band_mapping)
Parameters:

band_mapping – optional band mapping to override default band setting for SI calculation (see example above)

calc_si(si: str, collection) ndarray | MaskedArray[source]

Calculates the selected spectral index (SI) for spectral band data derived from ~eodal.core.RasterCollection. The resulting vi is returned as numpy.ndarray.

Parameters:
  • si – name of the selected vegetation index (e.g., NDVI). Raises an error if the vegetation index is not implemented/ found.

  • collection – ~`eodal.core.raster.RasterCollection` with spectral bands.

Returns:

2d numpy.ndarray or np.ma.MaskedArray with VI values (depends on array-type of the input)

get_si_list() List[str][source]

Returns a list of implemented Spectral Indices (SIs)

Returns:

list of SIs currently implemented