Skip to content

Commit

Permalink
Add formulas to indices docs (microsoft#400)
Browse files Browse the repository at this point in the history
* Add formulas to indices docs

* Use math text mode
  • Loading branch information
adamjstewart authored Feb 20, 2022
1 parent bab5584 commit ec867f0
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 10 deletions.
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

0 comments on commit ec867f0

Please sign in to comment.