Awesome Spectral Indices for the Google Earth Engine JavaScript API (Code Editor).
- GitHub: https://github.com/davemlz/spectral
- Documentation: https://ee-spectral.readthedocs.io/
- Awesome Spectral Indices for GEE: https://github.com/davemlz/awesome-ee-spectral-indices
- Examples/Tutorials: https://github.com/davemlz/spectral/tree/main/examples
Google Earth Engine (GEE) is a cloud-based service for geospatial processing of vector and raster data. The Earth Engine platform has a JavaScript and a Python API with different methods to process geospatial objects. Google Earth Engine also provides a HUGE PETABYTE-SCALE CATALOG of raster and vector data that users can process online. The Awesome Spectral Indices for GEE is a standardized ready-to-use curated list of spectral indices that can be used as expressions for computing spectral indices in GEE. The spectral module extends the GEE JavaScript API with new functions to access and compute spectral indices from the Awesome List of Spectral Indices.
Check the simple usage of spectral here:
var spectral = require("users/dmlmont/spectral:spectral");
var S2 = ee.ImageCollection("COPERNICUS/S2_SR").first()
var parameters = {
"N": S2.select("B8"),
"R": S2.select("B4"),
"G": S2.select("B3"),
"L": 0.5
};
var S2 = spectral.computeIndex(S2,["NDVI","GNDVI","SAVI"],parameters);
Check the full list of spectral indices here.
The spectral module can be accepted HERE. Once accepted, it can be required by running the following line in the GEE JavaScript Code Editor:
var spectral = require("users/dmlmont/spectral:spectral");
The complete list of spectral indices can be accessed by using the indices
attribute:
print(spectral.indices);
The list of available attributes for a specific index can be accessed using dot notation:
print(spectral.indices.NDVI);
Or by using a key:
print(spectral.indices["NDVI"]);
An attribute can be accessed using also dot notation:
print(spectral.indices.NDVI.formula);
Or by using a key:
print(spectral.indices.NDVI["formula"]);
The available attributes of an index are:
short_name
: Short name of the index (e.g."NDWI"
).long_name
: Long name of the index (e.g."Normalized Difference Water Index"
).formula
: Expression/formula of the index (e.g."(N - G)/(N + G)"
).bands
: List of required bands/parameters for the index computation (e.g.["N","G"]
).reference
: Link to the index reference/paper/doi (e.g."https://doi.org/10.1080/01431169608948714"
).type
: Type/application of the index (e.g."water"
).date_of_addition
: Date of addition to the list (e.g."2021-04-07"
).contributor
: GitHub user link of the contributor (e.g."https://github.com/davemlz"
).
Finally, an index (e.g. NDVI) can be computed using the computeIndex(img, index, params)
function:
var S2 = ee.ImageCollection("COPERNICUS/S2_SR").first()
var parameters = {
"N": S2.select("B8"),
"R": S2.select("B4"),
};
var S2 = spectral.computeIndex(S2,"NDVI",parameters);
And multiple indices can be computed using an array of indices:
var S2 = ee.ImageCollection("COPERNICUS/S2_SR").first()
var parameters = {
"N": S2.select("B8"),
"R": S2.select("B4"),
"G": S2.select("B3"),
"L": 0.5
};
var S2 = spectral.computeIndex(S2,["NDVI","GNDVI","SAVI"],parameters);
All specified indices are added as new bands.
The project is licensed under the MIT license.