Spectral Indices Computation

Let’s see how to compute built-in spectral indices with eemont!

Before anything, let’s import our modules and authenticate in Google Earth Engine:

import ee, eemont

ee.Authenticate()
ee.Initialize()

Now, we are ready to go!

Overview

The eemont package extends the ee.Image and ee.ImageCollection classes with the method spectralIndices():

ee.Image

spectralIndices(self[, index, G, C1, C2, L, …])

Computes one or more spectral indices (indices are added as bands) for an image from the Awesome List of Spectral Indices.

ee.ImageCollection

spectralIndices(self[, index, G, C1, C2, L, …])

Computes one or more spectral indices (indices are added as bands) for an image collection from the Awesome List of Spectral Indices.

List of Indices

The list of indices is retrieved from the Awesome List of Spectral Indices for Google Earth Engine

Vegetation Indices

The following table shows the list of built-in vegetation indices:

Built-in vegetation indices.

Index

Description

Reference

BNDVI

Blue Normalized Difference Vegetation Index

Index DataBase BNDVI

CIG

Chlorophyll Index - Green

Index DataBase CIG

CVI

Chlorophyll Vegetation Index

Index DataBase CVI

EVI

Enhanced Vegetation Index

Index DataBase EVI

EVI2

Two-Band Enhanced Vegetation Index

(Jiang et al., 2008)

GARI

Green Atmospherically Resistant Vegetation Index

Index DataBase GARI

GBNDVI

Green-Blue Normalized Difference Vegetation Index

Index DataBase GBNDVI

GEMI

Global Environment Monitoring Index

Index DataBase GEMI

GLI

Green Leaf Index

Index DataBase GLI

GNDVI

Green Normalized Difference Vegetation Index

Index DataBase GNDVI

GRNDVI

Green-Red Normalized Difference Vegetation Index

Index DataBase GRNDVI

GVMI

Global Vegetation Moisture Index

Index DataBase GVMI

MNDVI

Modified Normalized Difference Vegetation Index

Index DataBase MNDVI

NDVI

Normalized Difference Vegetation Index

Index DataBase NDVI

NGRDI

Normalized Green Red Difference Index

Index DataBase NGRDI

RVI

Ratio Vegetation Index

Index DataBase RVI

SAVI

Soil-Adjusted Vegetation Index

Index DataBase SAVI

VARI

Visible Atmospherically Resistant Index

Index DataBase VARI

Burn Indices

The following table shows the list of built-in burn indices:

Built-in burn indices.

Index

Description

Reference

BAI

Burned Area Index

(Martín, 1998) [spanish]

BAIS2

Burned Area Index for Sentinel 2

(Filipponi, 2018)

CSIT

Char Soil Index Thermal

(Smith et al., 2007)

NBR

Normalized Burn Ratio

Index DataBase NBR

NBRT

Normalized Burn Ratio Thermal

(Holden et al., 2005)

NDVIT

Normalized Difference Vegetation Index Thermal

(Smith et al., 2007)

SAVIT

Soil-Adjusted Vegetation Index Thermal

(Smith et al., 2007)

Water Indices

The following table shows the list of built-in water indices:

Built-in water indices.

Index

Description

Reference

MNDWI

Modified Normalized Difference Water Index

(Xu, 2006)

NDWI

Normalized Difference Water Index

(McFeeters, 1996)

Snow Indices

The following table shows the list of built-in snow indices:

Built-in snow indices.

Index

Description

Reference

NDSI

Normalized Difference Snow Index

(Riggs et al., 1994)

Drought Indices

The following table shows the list of built-in drought indices:

Built-in snow indices.

Index

Description

Reference

NDDI

Normalized Difference Drought Index

(Gu et al., 2007)

Generalized Kernel Indices

The following table shows the list of built-in kernel indices:

Built-in kernel indices.

Index

Description

Reference

kEVI

Kernel Enhanced Vegetation Index

(Camps-Valls et al., 2021)

kNDVI

Kernel Normalized Difference Vegetation Index

(Camps-Valls et al., 2021)

kRVI

Kernel Ratio Vegetation Index

(Camps-Valls et al., 2021)

kVARI

Kernel Visible Atmospherically Resistant Index

(Camps-Valls et al., 2021)

Kernels

In the case of generalized kernel indices, the following kernels are available:

Linear Kernel

The linear kernel for generalized kernel indices can be selected by setting kernel = 'linear'.

\[k(a,b) = ab\]

RBF Kernel

The Radial Basis Function (RBF) kernel for generalized kernel indices can be selected by setting kernel = 'RBF'.

\[k(a,b) = exp(- \frac{(a - b) ^ 2}{2 \sigma ^ 2})\]

Where \(\sigma\) is a free length-scale parameter.

Polynomial Kernel

The polynomial kernel for generalized kernel indices can be selected by setting kernel = 'poly'.

\[k(a,b) = (ab + c) ^ p\]

Where \(c\) is a free parameter that trades off the influence of higher-order versus lower-order terms and \(p\) is the kernel degree.

List of Bands

The following table shows the list of bands used for spectral indices computation:

Bands used for spectral indices computation.

Description

Name

Sentinel-2

Landsat 8

Landsat 457

MODIS

Aerosols

A

B1

B1

Blue

B

B2

B2

B1

B3

Green

G

B3

B3

B2

B4

Red

R

B4

B4

B3

B1

Red Edge 1

RE1

B5

Red Edge 2

RE2

B6

Red Edge 3

RE3

B7

Red Edge 4

RE4

B8A

NIR

N

B8

B5

B4

B2

SWIR 1

S1

B11

B6

B5

B6

SWIR 2

S2

B12

B7

B7

B7

Thermal 1

T1

B10

B6

Thermal 2

T2

B11

Warning

If the satellite platform doesn’t have the required bands for computing an index, it won’t be computed.

Usage

The spectralIndices() method computes the specified spectral index and adds it as a new band.

Let’s take the Sentinel-2 SR image collection as example (remember to scale your image or image collection!):

S2 = ee.ImageCollection('COPERNICUS/S2_SR').scaleAndOffset()

By default, the spectralIndices() method computes the NDVI:

S2withIndices = S2.spectralIndices()
S2withIndices.select('NDVI')

If required, any of the above-mentioned indices can be computed by modifying the index parameter:

S2withIndices = S2.spectralIndices(index = 'EVI')
S2withIndices.select('EVI')

Specific index-parameters can be changed, for example, the canopy background adjustment L is set to 1.0 for EVI, but for SAVI it can be changed to 0.5:

S2withIndices = S2.spectralIndices('SAVI',L = 0.5)
S2withIndices.select('SAVI')

If more than one index is required, a list of indices can be used:

S2withIndices = S2.spectralIndices(['CIG','NBR','NDWI'])
S2withIndices.select('CIG')
S2withIndices.select('NBR')
S2withIndices.select('NDWI')

Indices can also be computed for single images:

S2withIndices = S2.first().spectralIndices(['GBNDVI','MNDVI','EVI'])
S2withIndices.select('GBNDVI')
S2withIndices.select('MNDVI')
S2withIndices.select('EVI')

All vegetation indices can be computed by setting index = vegetation:

S2withIndices = S2.spectralIndices('vegetation')
S2withIndices.select('NDVI')
S2withIndices.select('GNDVI')
S2withIndices.select('RVI')
# ...

All burn indices can be computed by setting index = burn:

S2withIndices = S2.spectralIndices('burn')
S2withIndices.select('BAI')
S2withIndices.select('BAIS2')
S2withIndices.select('NBR')

All water indices can be computed by setting index = water:

S2withIndices = S2.spectralIndices('water')
S2withIndices.select('NDWI')
S2withIndices.select('MNDWI')

All snow indices can be computed by setting index = snow:

S2withIndices = S2.spectralIndices('snow')
S2withIndices.select('NDSI')

If you want to compute all available indices, you can set index = all:

S2withIndices = S2.spectralIndices('all')
S2withIndices.select('NDVI')
S2withIndices.select('BAI')
S2withIndices.select('NDWI')
S2withIndices.select('NDSI')
# ...

Generalized Kernel Indices

Generalized kernel indices are availabe through eemont (e.g. kNDVI):

S2withIndices = S2.spectralIndices('kNDVI')
S2withIndices.select('kNDVI')

By default, the RBF kernel is used and the sigma parameter is 0.5 * (a + b) (this means, that for k(N,R), sigma = '0.5 * (N + R)'). If required, sigma can be modified by another expression (using a and b) or a float:

S2withIndices = S2.spectralIndices('kNDVI',sigma = 1)
S2withIndices.select('kNDVI')

The kernel can be modified by modifying the kernel parameter:

S2withIndices = S2.spectralIndices('kNDVI',kernel = 'poly')
S2withIndices.select('kNDVI')

For the polynomial kernel, the p and c parameters can be modified:

S2withIndices = S2.spectralIndices('kNDVI',kernel = 'poly',p = 4,c = 0)
S2withIndices.select('kNDVI')

All kernel indices can be computed by setting index = kernel:

S2withIndices = S2.spectralIndices('kernel')
S2withIndices.select('kEVI')
S2withIndices.select('kNDVI')
S2withIndices.select('kRVI')
S2withIndices.select('kVARI')