зеркало из https://github.com/microsoft/torchgeo.git
Add BNDVI/NDRE spectral indices (#386)
This commit is contained in:
Родитель
019dc2495d
Коммит
16774fb6f4
|
@ -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)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче