diff --git a/openeo/extra/spectral_indices/__init__.py b/openeo/extra/spectral_indices/__init__.py index 63c80c476..1f4a0e797 100644 --- a/openeo/extra/spectral_indices/__init__.py +++ b/openeo/extra/spectral_indices/__init__.py @@ -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 -""" \ No newline at end of file +from openeo.extra.spectral_indices.spectral_indices import * diff --git a/openeo/extra/spectral_indices/resources/README.md b/openeo/extra/spectral_indices/resources/README.md new file mode 100644 index 000000000..9892ae227 --- /dev/null +++ b/openeo/extra/spectral_indices/resources/README.md @@ -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 + diff --git a/openeo/extra/spectral_indices/resources/awesome-spectral-indices/LICENSE b/openeo/extra/spectral_indices/resources/awesome-spectral-indices/LICENSE new file mode 100644 index 000000000..7bd30da58 --- /dev/null +++ b/openeo/extra/spectral_indices/resources/awesome-spectral-indices/LICENSE @@ -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. diff --git a/openeo/extra/spectral_indices/resources/spectral-indices-dict.json b/openeo/extra/spectral_indices/resources/awesome-spectral-indices/spectral-indices-dict.json similarity index 88% rename from openeo/extra/spectral_indices/resources/spectral-indices-dict.json rename to openeo/extra/spectral_indices/resources/awesome-spectral-indices/spectral-indices-dict.json index d473032e6..d7c026662 100644 --- a/openeo/extra/spectral_indices/resources/spectral-indices-dict.json +++ b/openeo/extra/spectral_indices/resources/awesome-spectral-indices/spectral-indices-dict.json @@ -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": [ @@ -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": [ @@ -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", @@ -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": [ @@ -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", @@ -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": [ @@ -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": [ @@ -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", @@ -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": [ @@ -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", @@ -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": [ @@ -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": [ @@ -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", diff --git a/openeo/extra/spectral_indices/resources/vito-indices-dict.json b/openeo/extra/spectral_indices/resources/extra-indices-dict.json similarity index 100% rename from openeo/extra/spectral_indices/resources/vito-indices-dict.json rename to openeo/extra/spectral_indices/resources/extra-indices-dict.json diff --git a/openeo/extra/spectral_indices/spectral_indices.py b/openeo/extra/spectral_indices/spectral_indices.py index 151de9495..f55ef7e15 100644 --- a/openeo/extra/spectral_indices/spectral_indices.py +++ b/openeo/extra/spectral_indices/spectral_indices.py @@ -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"]) diff --git a/tests/extra/spectral_indices/test_spectral_indices.py b/tests/extra/spectral_indices/test_spectral_indices.py index cc1584508..80fe2f893 100644 --- a/tests/extra/spectral_indices/test_spectral_indices.py +++ b/tests/extra/spectral_indices/test_spectral_indices.py @@ -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