Computing Spectral Indices for MODIS
Tutorial created by **David Montero Loaiza**: GitHub | Twitter
GitHub Repo: https://github.com/davemlz/eemont
PyPI link: https://pypi.org/project/eemont/
Conda-forge: https://anaconda.org/conda-forge/eemont
Documentation: https://eemont.readthedocs.io/
More tutorials: https://github.com/davemlz/eemont/tree/master/docs/tutorials
Let’s start!
If required, please uncomment:
[1]:
#!pip install eemont
#!pip install geemap
Import the required packages.
[2]:
import ee, eemont, geemap
Update geemap:
[3]:
geemap.update_package()
Downloading https://github.com/giswqs/geemap/archive/master.zip ...
Unzipping geemap-master.zip ...
Data downloaded to: /home/dmontero/Downloads/geemap-master
Please comment out 'geemap.update_package()' and restart the kernel to take effect:
Jupyter menu -> Kernel -> Restart & Clear Output
Authenticate and Initialize Earth Engine and geemap.
[4]:
Map = geemap.Map()
Preprocessing and Spectral Indices Computation
Now, spectral indices can be computed for MODIS Surface Reflectance products using the index() extended method:
[5]:
MOD09GA = (ee.ImageCollection('MODIS/006/MOD09GA')
.filterDate('2020-01-01','2021-01-01')
.maskClouds()
.scaleAndOffset()
.spectralIndices(['GNDVI','NBR','NDWI'])
.median())
Let’s visualize our indices!
[6]:
import geemap.colormaps as cm
Colormaps from the geemap package:
[7]:
vegetationPalette = cm.palettes.ndvi
waterPalette = cm.palettes.ndwi
burnPalette = cm.palettes.inferno
Visualization parameters:
[8]:
GNDVIvis = {'min':0,'max':1,'palette':vegetationPalette,'bands':'GNDVI'}
NBRvis = {'min':0,'max':1,'palette':burnPalette,'bands':'NBR'}
NDWIvis = {'min':0,'max':1,'palette':waterPalette,'bands':'NDWI'}
Area of Interest (Let’s use queries here!):
[9]:
aoi = ee.Geometry.PointFromQuery('Lago Cocibolca, Nicaragua',user_agent = 'eemont-tutorial-012')
GNDVI
[10]:
Map.addLayer(MOD09GA,GNDVIvis,'GNDVI')
Map.add_colorbar(GNDVIvis['palette'],caption = 'GNDVI')
Map.centerObject(aoi,8)
Map
NBR
[11]:
Map2 = geemap.Map()
Map2.addLayer(MOD09GA,NBRvis,'NBR')
Map2.add_colorbar(NBRvis['palette'],caption = 'NBR')
Map2.centerObject(aoi,8)
Map2
NDWI
[12]:
Map3 = geemap.Map()
Map3.addLayer(MOD09GA,NDWIvis,'NDWI')
Map3.add_colorbar(NDWIvis['palette'],caption = 'NDWI')
Map3.centerObject(aoi,8)
Map3