Add BNDVI/NDRE spectral indices (#386)

This commit is contained in:
Data Philosopher 2022-02-15 03:23:03 +05:30 коммит произвёл GitHub
Родитель 019dc2495d
Коммит 16774fb6f4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 57 добавлений и 1 удалений

Просмотреть файл

@ -8,9 +8,11 @@ import torch
from torch import Tensor from torch import Tensor
from torchgeo.transforms import ( from torchgeo.transforms import (
AppendBNDVI,
AppendGNDVI, AppendGNDVI,
AppendNBR, AppendNBR,
AppendNDBI, AppendNDBI,
AppendNDRE,
AppendNDSI, AppendNDSI,
AppendNDVI, AppendNDVI,
AppendNDWI, AppendNDWI,
@ -64,7 +66,17 @@ def test_append_index_batch(batch: Dict[str, Tensor]) -> None:
@pytest.mark.parametrize( @pytest.mark.parametrize(
"index", "index",
[AppendNBR, AppendNDBI, AppendNDSI, AppendNDVI, AppendNDWI, AppendSWI, AppendGNDVI], [
AppendBNDVI,
AppendNBR,
AppendNDBI,
AppendNDRE,
AppendNDSI,
AppendNDVI,
AppendNDWI,
AppendSWI,
AppendGNDVI,
],
) )
def test_append_normalized_difference_indices( def test_append_normalized_difference_indices(
sample: Dict[str, Tensor], index: AppendNormalizedDifferenceIndex sample: Dict[str, Tensor], index: AppendNormalizedDifferenceIndex

Просмотреть файл

@ -4,9 +4,11 @@
"""TorchGeo transforms.""" """TorchGeo transforms."""
from .indices import ( from .indices import (
AppendBNDVI,
AppendGNDVI, AppendGNDVI,
AppendNBR, AppendNBR,
AppendNDBI, AppendNDBI,
AppendNDRE,
AppendNDSI, AppendNDSI,
AppendNDVI, AppendNDVI,
AppendNDWI, AppendNDWI,
@ -17,9 +19,11 @@ from .transforms import AugmentationSequential
__all__ = ( __all__ = (
"AppendNormalizedDifferenceIndex", "AppendNormalizedDifferenceIndex",
"AppendBNDVI",
"AppendGNDVI", "AppendGNDVI",
"AppendNBR", "AppendNBR",
"AppendNDBI", "AppendNDBI",
"AppendNDRE",
"AppendNDSI", "AppendNDSI",
"AppendNDVI", "AppendNDVI",
"AppendNDWI", "AppendNDWI",

Просмотреть файл

@ -201,3 +201,43 @@ class AppendGNDVI(AppendNormalizedDifferenceIndex):
index_green: index of the Green band, e.g. B3 in Sentinel 2 imagery index_green: index of the Green band, e.g. B3 in Sentinel 2 imagery
""" """
super().__init__(index_a=index_nir, index_b=index_green) super().__init__(index_a=index_nir, index_b=index_green)
class AppendBNDVI(AppendNormalizedDifferenceIndex):
"""Blue Normalized Difference Vegetation Index (BNDVI).
If you use this index in your research, please cite the following paper:
* https://doi.org/10.1016/S1672-6308(07)60027-4
.. versionadded:: 0.3
"""
def __init__(self, index_nir: int, index_blue: int) -> None:
"""Initialize a new transform instance.
Args:
index_nir: index of the NIR band, e.g. B8 in Sentinel 2 imagery
index_blue: index of the Blue band, e.g. B2 in Sentinel 2 imagery
"""
super().__init__(index_a=index_nir, index_b=index_blue)
class AppendNDRE(AppendNormalizedDifferenceIndex):
"""Normalized Difference Red Edge Vegetation Index (NDRE).
If you use this index in your research, please cite the following paper:
* https://agris.fao.org/agris-search/search.do?recordID=US201300795763
.. versionadded:: 0.3
"""
def __init__(self, index_nir: int, index_vre1: int) -> None:
"""Initialize a new transform instance.
Args:
index_nir: index of the NIR band, e.g. B8 in Sentinel 2 imagery
index_vre1: index of the Red Edge band, B5 in Sentinel 2 imagery
"""
super().__init__(index_a=index_nir, index_b=index_vre1)