Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add formulas to indices docs #400

Merged
merged 2 commits into from
Feb 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx.ext.mathjax",
"sphinx.ext.napoleon",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
Expand Down
80 changes: 70 additions & 10 deletions torchgeo/transforms/indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@


class AppendNormalizedDifferenceIndex(Module):
"""Append normalized difference index as channel to image tensor.
r"""Append normalized difference index as channel to image tensor.

Computes the following index:

.. math::

\text{NDI} = \frac{A - B}{A + B}

.. versionadded:: 0.2
"""
Expand Down Expand Up @@ -76,7 +82,13 @@ def forward(self, sample: Dict[str, Tensor]) -> Dict[str, Tensor]:


class AppendNBR(AppendNormalizedDifferenceIndex):
"""Normalized Burn Ratio (NBR).
r"""Normalized Burn Ratio (NBR).

Computes the following index:

.. math::

\text{NBR} = \frac{\text{NIR} - \text{SWIR}}{\text{NIR} + \text{SWIR}}

If you use this index in your research, please cite the following paper:

Expand All @@ -96,7 +108,13 @@ def __init__(self, index_nir: int, index_swir: int) -> None:


class AppendNDBI(AppendNormalizedDifferenceIndex):
"""Normalized Difference Built-up Index (NDBI).
r"""Normalized Difference Built-up Index (NDBI).

Computes the following index:

.. math::

\text{NDBI} = \frac{\text{SWIR} - \text{NIR}}{\text{SWIR} + \text{NIR}}

If you use this index in your research, please cite the following paper:

Expand All @@ -114,7 +132,13 @@ def __init__(self, index_swir: int, index_nir: int) -> None:


class AppendNDSI(AppendNormalizedDifferenceIndex):
"""Normalized Difference Snow Index (NDSI).
r"""Normalized Difference Snow Index (NDSI).

Computes the following index:

.. math::

\text{NDSI} = \frac{\text{G} - \text{SWIR}}{\text{G} + \text{SWIR}}

If you use this index in your research, please cite the following paper:

Expand All @@ -132,7 +156,13 @@ def __init__(self, index_green: int, index_swir: int) -> None:


class AppendNDVI(AppendNormalizedDifferenceIndex):
"""Normalized Difference Vegetation Index (NDVI).
r"""Normalized Difference Vegetation Index (NDVI).

Computes the following index:

.. math::

\text{NDVI} = \frac{\text{R} - \text{NIR}}{\text{R} + \text{NIR}}

If you use this index in your research, please cite the following paper:

Expand All @@ -150,7 +180,13 @@ def __init__(self, index_red: int, index_nir: int) -> None:


class AppendNDWI(AppendNormalizedDifferenceIndex):
"""Normalized Difference Water Index (NDWI).
r"""Normalized Difference Water Index (NDWI).

Computes the following index:

.. math::

\text{NDWI} = \frac{\text{G} - \text{NIR}}{\text{G} + \text{NIR}}

If you use this index in your research, please cite the following paper:

Expand All @@ -168,7 +204,13 @@ def __init__(self, index_green: int, index_nir: int) -> None:


class AppendSWI(AppendNormalizedDifferenceIndex):
"""Standardized Water-Level Index (SWI).
r"""Standardized Water-Level Index (SWI).

Computes the following index:

.. math::

\text{SWI} = \frac{\text{R} - \text{SWIR}}{\text{R} + \text{SWIR}}

If you use this index in your research, please cite the following paper:

Expand All @@ -186,7 +228,13 @@ def __init__(self, index_red: int, index_swir: int) -> None:


class AppendGNDVI(AppendNormalizedDifferenceIndex):
"""Green Normalized Difference Vegetation Index (GNDVI).
r"""Green Normalized Difference Vegetation Index (GNDVI).

Computes the following index:

.. math::

\text{GNDVI} = \frac{\text{NIR} - \text{G}}{\text{NIR} + \text{G}}

If you use this index in your research, please cite the following paper:

Expand All @@ -204,7 +252,13 @@ def __init__(self, index_nir: int, index_green: int) -> None:


class AppendBNDVI(AppendNormalizedDifferenceIndex):
"""Blue Normalized Difference Vegetation Index (BNDVI).
r"""Blue Normalized Difference Vegetation Index (BNDVI).

Computes the following index:

.. math::

\text{BNDVI} = \frac{\text{NIR} - \text{B}}{\text{NIR} + \text{B}}

If you use this index in your research, please cite the following paper:

Expand All @@ -224,7 +278,13 @@ def __init__(self, index_nir: int, index_blue: int) -> None:


class AppendNDRE(AppendNormalizedDifferenceIndex):
"""Normalized Difference Red Edge Vegetation Index (NDRE).
r"""Normalized Difference Red Edge Vegetation Index (NDRE).

Computes the following index:

.. math::

\text{NDRE} = \frac{\text{NIR} - \text{VRE1}}{\text{NIR} + \text{VRE1}}

If you use this index in your research, please cite the following paper:

Expand Down