normalized_difference#

geodesic.boson.normalized_difference(asset_band_1, asset_band_2, asset_name, band_name='calculated')[source]#

Creates a new asset by calculating the normalized difference between two bands.

The normalized difference is calculated as (band_1 - band_2) / (band_1 + band_2).

A common index, NDVI, is calculated by: (NIR - Red) / (NIR + Red)

Parameters:
  • asset_band_1 (AssetBands) – asset band for the first band

  • asset_band_2 (AssetBands) – asset band for the second band

  • asset_name (str) – name of the asset to create

  • band_name (str) – name of the band to create. Defaults to “calculated”

Returns:

middleware to calculate the normalized difference between two bands

Return type:

Middleware

Examples

>>> # Calculate NDVI using band names
>>> transform = normalized_difference(
...     asset_band_1=AssetBands(asset="image", bands=["nir"]),
...     asset_band_2=AssetBands(asset="image", bands=["red"]),
...     asset_name="ndvi"
... )
>>> # Calculate NDVI using band IDs
>>> transform = normalized_difference(
...     asset_band_1=AssetBands(asset="nir", bands=[0]),
...     asset_band_2=AssetBands(asset="red", bands=[0]),
...     asset_name="ndvi"
... )