Skip to content

Commit

Permalink
EP-4053/#255 reorganise file structure a bit and update spectral-indi…
Browse files Browse the repository at this point in the history
…ces-dict.json
  • Loading branch information
soxofaan committed Nov 16, 2021
1 parent 4673945 commit 57df192
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 23 deletions.
6 changes: 2 additions & 4 deletions openeo/extra/spectral_indices/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""
Calculate spectral indices (vegetation indices, water indices, etc.) in one line
"""

The indices implemented have been derived from the eemont package created by davemlz:
https://github.com/davemlz/eemont/blob/master/eemont/data/spectral-indices-dict.json
and further supplemented with indices that were necessary for use cases
"""
from openeo.extra.spectral_indices.spectral_indices import *
8 changes: 8 additions & 0 deletions openeo/extra/spectral_indices/resources/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

Spectral Index specification files, derived from and based on the
[Awesome Spectral Indices](https://awesome-ee-spectral-indices.readthedocs.io/) project
by [David Montero Loaiza](https://github.com/davemlz)

- `awesome-spectral-indices/spectral-indices-dict.json` comes straight from https://github.com/davemlz/awesome-spectral-indices/blob/main/output/spectral-indices-dict.json
- `extra-indixes-dict.json` is a set of additional indices not (yet) provided by Awesome Spectral Indices

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 David Montero Loaiza

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@
"long_name": "Enhanced Vegetation Index",
"reference": "https://doi.org/10.1016/S0034-4257(96)00112-5",
"short_name": "EVI",
"type": "vegetation",
"range": "(-3,3)"
"type": "vegetation"
},
"EVI2": {
"bands": [
Expand All @@ -243,8 +242,7 @@
"long_name": "Two-Band Enhanced Vegetation Index",
"reference": "https://doi.org/10.1016/j.rse.2008.06.006",
"short_name": "EVI2",
"type": "vegetation",
"range": "(-3,3)"
"type": "vegetation"
},
"ExG": {
"bands": [
Expand Down Expand Up @@ -427,6 +425,49 @@
"short_name": "MCARI2",
"type": "vegetation"
},
"MCARI705": {
"bands": [
"RE2",
"RE1",
"G"
],
"contributor": "https://github.com/davemlz",
"date_of_addition": "2021-11-06",
"formula": "((RE2 - RE1) - 0.2 * (RE2 - G)) * (RE2 / RE1)",
"long_name": "Modified Chlorophyll Absorption in Reflectance Index (705 and 750 nm)",
"reference": "https://doi.org/10.1016/j.agrformet.2008.03.005",
"short_name": "MCARI705",
"type": "vegetation"
},
"MCARIOSAVI": {
"bands": [
"RE1",
"R",
"G",
"N"
],
"contributor": "https://github.com/davemlz",
"date_of_addition": "2021-11-06",
"formula": "(((RE1 - R) - 0.2 * (RE1 - G)) * (RE1 / R)) / (1.16 * (N - R) / (N + R + 0.16))",
"long_name": "MCARI/OSAVI Ratio",
"reference": "https://doi.org/10.1016/S0034-4257(00)00113-9",
"short_name": "MCARIOSAVI",
"type": "vegetation"
},
"MCARIOSAVI705": {
"bands": [
"RE2",
"RE1",
"G"
],
"contributor": "https://github.com/davemlz",
"date_of_addition": "2021-11-06",
"formula": "(((RE2 - RE1) - 0.2 * (RE2 - G)) * (RE2 / RE1)) / (1.16 * (RE2 - RE1) / (RE2 + RE1 + 0.16))",
"long_name": "MCARI/OSAVI Ratio (705 and 750 nm)",
"reference": "https://doi.org/10.1016/j.agrformet.2008.03.005",
"short_name": "MCARIOSAVI705",
"type": "vegetation"
},
"MGRVI": {
"bands": [
"G",
Expand Down Expand Up @@ -464,8 +505,7 @@
"long_name": "Modified Normalized Difference Water Index",
"reference": "https://doi.org/10.1080/01431160600589179",
"short_name": "MNDWI",
"type": "water",
"range": "(-1,1)"
"type": "water"
},
"MNLI": {
"bands": [
Expand Down Expand Up @@ -507,6 +547,19 @@
"short_name": "MSR",
"type": "vegetation"
},
"MSR705": {
"bands": [
"RE2",
"RE1"
],
"contributor": "https://github.com/davemlz",
"date_of_addition": "2021-11-06",
"formula": "(RE2 / RE1 - 1) / ((RE2 / RE1 + 1) ** 0.5)",
"long_name": "Modified Simple Ratio (705 and 750 nm)",
"reference": "https://doi.org/10.1016/j.agrformet.2008.03.005",
"short_name": "MSR705",
"type": "vegetation"
},
"MTCI": {
"bands": [
"RE2",
Expand Down Expand Up @@ -560,8 +613,7 @@
"long_name": "Normalized Burn Ratio",
"reference": "https://www.usgs.gov/core-science-systems/nli/landsat/landsat-normalized-burn-ratio",
"short_name": "NBR",
"type": "burn",
"range": "(-1,1)"
"type": "burn"
},
"NBR2": {
"bands": [
Expand All @@ -574,8 +626,7 @@
"long_name": "Normalized Burn Ratio 2",
"reference": "https://www.usgs.gov/core-science-systems/nli/landsat/landsat-normalized-burn-ratio-2",
"short_name": "NBR2",
"type": "burn",
"range": "(-3,3)"
"type": "burn"
},
"NBRT": {
"bands": [
Expand Down Expand Up @@ -683,6 +734,19 @@
"short_name": "NDVI",
"type": "vegetation"
},
"NDVI705": {
"bands": [
"RE2",
"RE1"
],
"contributor": "https://github.com/davemlz",
"date_of_addition": "2021-11-06",
"formula": "(RE2 - RE1) / (RE2 + RE1)",
"long_name": "Normalized Difference Vegetation Index (705 and 750 nm)",
"reference": "https://doi.org/10.1016/S0176-1617(11)81633-0",
"short_name": "NDVI705",
"type": "vegetation"
},
"NDVIT": {
"bands": [
"N",
Expand All @@ -708,8 +772,7 @@
"long_name": "Normalized Difference Water Index",
"reference": "https://doi.org/10.1080/01431169608948714",
"short_name": "NDWI",
"type": "water",
"range": "(-1,1)"
"type": "water"
},
"NDYI": {
"bands": [
Expand Down Expand Up @@ -844,6 +907,20 @@
"short_name": "RDVI",
"type": "vegetation"
},
"REDSI": {
"bands": [
"RE3",
"R",
"RE1"
],
"contributor": "https://github.com/davemlz",
"date_of_addition": "2021-11-06",
"formula": "((705.0 - 665.0) * (RE3 - R) - (783.0 - 665.0) * (RE1 - R)) / (2.0 * R)",
"long_name": "Red-Edge Disease Stress Index",
"reference": "https://doi.org/10.3390/s18030868",
"short_name": "REDSI",
"type": "vegetation"
},
"RVI": {
"bands": [
"N",
Expand Down Expand Up @@ -913,8 +990,7 @@
"long_name": "Soil-Adjusted Vegetation Index",
"reference": "https://doi.org/10.1016/0034-4257(88)90106-X",
"short_name": "SAVI",
"type": "vegetation",
"range": "(-3,3)"
"type": "vegetation"
},
"SAVI2": {
"bands": [
Expand Down Expand Up @@ -958,8 +1034,33 @@
"long_name": "Structure Insensitive Pigment Index",
"reference": "https://eurekamag.com/research/009/395/009395053.php",
"short_name": "SIPI",
"type": "vegetation",
"range": "(-10,10)"
"type": "vegetation"
},
"SR555": {
"bands": [
"RE2",
"G"
],
"contributor": "https://github.com/davemlz",
"date_of_addition": "2021-11-06",
"formula": "RE2 / G",
"long_name": "Simple Ratio (555 and 750 nm)",
"reference": "https://doi.org/10.1016/S0176-1617(11)81633-0",
"short_name": "SR555",
"type": "vegetation"
},
"SR705": {
"bands": [
"RE2",
"RE1"
],
"contributor": "https://github.com/davemlz",
"date_of_addition": "2021-11-06",
"formula": "RE2 / RE1",
"long_name": "Simple Ratio (705 and 750 nm)",
"reference": "https://doi.org/10.1016/S0176-1617(11)81633-0",
"short_name": "SR705",
"type": "vegetation"
},
"SWI": {
"bands": [
Expand Down Expand Up @@ -1002,6 +1103,35 @@
"short_name": "TCARI",
"type": "vegetation"
},
"TCARIOSAVI": {
"bands": [
"RE1",
"R",
"G",
"N"
],
"contributor": "https://github.com/davemlz",
"date_of_addition": "2021-11-06",
"formula": "(3 * ((RE1 - R) - 0.2 * (RE1 - G) * (RE1 / R))) / (1.16 * (N - R) / (N + R + 0.16))",
"long_name": "TCARI/OSAVI Ratio",
"reference": "https://doi.org/10.1016/S0034-4257(02)00018-4",
"short_name": "TCARIOSAVI",
"type": "vegetation"
},
"TCARIOSAVI705": {
"bands": [
"RE2",
"RE1",
"G"
],
"contributor": "https://github.com/davemlz",
"date_of_addition": "2021-11-06",
"formula": "(3 * ((RE2 - RE1) - 0.2 * (RE2 - G) * (RE2 / RE1))) / (1.16 * (RE2 - RE1) / (RE2 + RE1 + 0.16))",
"long_name": "TCARI/OSAVI Ratio (705 and 750 nm)",
"reference": "https://doi.org/10.1016/j.agrformet.2008.03.005",
"short_name": "TCARIOSAVI705",
"type": "vegetation"
},
"TCI": {
"bands": [
"RE1",
Expand Down
4 changes: 2 additions & 2 deletions openeo/extra/spectral_indices/spectral_indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def load_indices() -> Dict[str, dict]:
resource_dir = Path(__file__).parent / "resources"
specs = {}
for path in [
resource_dir / "spectral-indices-dict.json",
resource_dir / "vito-indices-dict.json"
resource_dir / "awesome-spectral-indices/spectral-indices-dict.json",
resource_dir / "extra-indices-dict.json"
]:
with path.open("r") as f:
specs.update(json.load(f)["SpectralIndices"])
Expand Down
2 changes: 1 addition & 1 deletion tests/extra/spectral_indices/test_spectral_indices.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List, Union

from openeo.extra.spectral_indices.spectral_indices import append_and_rescale_indices, compute_and_rescale_indices, \
from openeo.extra.spectral_indices import append_and_rescale_indices, compute_and_rescale_indices, \
compute_indices, append_indices, compute_index, append_index, list_indices, load_indices
from openeo.rest.datacube import DataCube

Expand Down

0 comments on commit 57df192

Please sign in to comment.