Lesson 1. Calculate Vegetation Indices in Python


NAIP, Landsat, MODIS and Vegetation Indices in Python - Intermediate earth data science textbook course module

Welcome to the first lesson in the NAIP, Landsat, MODIS and Vegetation Indices in Python module. Learn how to calculate vegetation indices from multispectral remote sensing data in Python.

Chapter Eleven - Calculate Vegetation Indices From Remote Sensing Data Using Python

In this chapter, you will learn how to calculate vegetation indices such as normalized difference vegetation index (NDVI) and normalized burn ratio (NBR) from multispectral remote sensing data in Python.

Learning Objectives

After completing this tutorial, you will be able to:

  • Describe what a vegetation index is and how it is used with spectral remote sensing data.
  • Describe how the NDVI index is used to quantify vegetation health (greeness).
  • Calculate NDVI using multispectral imagery in Python.
  • Describe how the dNBR index is used to quantify fire severity.
  • Calculate dNBR using multispectral imagery in Python.

What You Need

You will need a computer with internet access to complete this lesson and the Cold Springs Fire data.

Download Cold Springs Fire Data (~150 MB)

Or use earthpy et.data.get_data('cold-springs-fire')

About Vegetation Indices

A vegetation index is a single value that quantifies vegetation health or structure. The math associated with calculating a vegetation index is derived from the physics of light reflection and absorption across bands. For instance, it is known that healthy vegetation reflects light strongly in the near infrared band and less strongly in the visible portion of the spectrum.

Thus, if you create a ratio between light reflected in the near infrared and light reflected in the visible spectrum, it will represent areas that potentially have healthy vegetation.

Normalized Difference Vegetation Index (NDVI)

The Normalized Difference Vegetation Index (NDVI) is a quantitative index of greenness ranging from 0-1 where 0 represents minimal or no greenness and 1 represents maximum greenness.

NDVI is often used for a quantitate proxy measure of vegetation health, cover and phenology (life cycle stage) over large areas.

NDVI image from NASA that shows reflectance.
NDVI is calculated from the visible and near-infrared light reflected by vegetation. Healthy vegetation (left) absorbs most of the visible light that hits it, and reflects a large portion of near-infrared light. Unhealthy or sparse vegetation (right) reflects more visible light and less near-infrared light. Source: NASA

How to Derive the NDVI Vegetation Index From Multispectral Imagery

The normalized difference vegetation index (NDVI) uses a ratio between near infrared and red light within the electromagnetic spectrum. To calculate NDVI you use the following formula where NIR is near infrared light and red represents red light. For your raster data, you will take the reflectance value in the red and near infrared bands to calculate the index.

(NIR - Red) / (NIR + Red)

/opt/conda/envs/EDS/lib/python3.8/site-packages/rasterio/plot.py:263: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if len(arr.shape) is 2:
Plotting the NDVI calculation of the 2015 NAIP data with a colorbar that reflects the data.
Plotting the NDVI calculation of the 2015 NAIP data with a colorbar that reflects the data.

Normalized Burn Ratio (NBR)

The Normalized burn ratio (NBR) is used to identify burned areas. The formula is similar to a normalized difference vegetation index (NDVI), except that it uses near-infrared (NIR) and shortwave-infrared (SWIR) portions of the electromagnetic spectrum (Lopez, 1991; Key and Benson, 1995).

NBR - US Forest Service.
The normalized burn ratio (NBR) index uses the shortwave-infrared (SWIR) and near-infrared (NIR) portions of the electromagnetic spectrum.

The NIR and SWIR parts of the electromagnetic spectrum are a powerful combination of bands to use for this index given vegetation reflects strongly in the NIR region of the electromagnetic spectrum and weakly in the SWIR. Alternatively, it has been shown that a fire scar which contains scarred woody vegetation and earth will reflect more strongly in the SWIR part of the electromagnetic spectrum and beyond (see figure below).

NBR - US Forest Service.
Plants reflect strongly in the NIR portion of the spectrum but spectrun. reflect much less strongly in the SWIR portion which makes this combination powerful for identifying areas with standing dead stems (fire scarred wood / bark) and soil / earth. Source: US Forest Service

NBR Bands

The NBR index was originally developed for use with Landsat TM and ETM+ bands 4 and 7, but it will work with any multispectral sensor with a NIR band between 760 - 900 nm and a SWIR band between 2080 - 2350 nm. Thus this index can be used with both Landsat 8, MODIS and other multi (and hyper) spectral sensors.

NBR & Landsat 8

The table below which shows the band distribution of Landsat 8. These bands are different from Landsat 7. What bands should you use to calculate NBR using Landsat 8?

Landsat 8 Bands

BandWavelength range (nanometers)Spatial Resolution (m)Spectral Width (nm)
Band 1 - Coastal aerosol430 - 450302.0
Band 2 - Blue450 - 510306.0
Band 3 - Green530 - 590306.0
Band 4 - Red640 - 670300.03
Band 5 - Near Infrared (NIR)850 - 880303.0
Band 6 - SWIR 11570 - 1650308.0
Band 7 - SWIR 22110 - 22903018
Band 8 - Panchromatic500 - 6801518
Band 9 - Cirrus1360 - 1380302.0

NBR & MODIS

Similarly the table below shows the band ranges for the MODIS sensor. What bands should you use to calculate NBR using MODIS?

BandWavelength range (nm)Spatial Resolution (m)Spectral Width (nm)
Band 1 - red620 - 6702502.0
Band 2 - near infrared841 - 8762506.0
Band 3 - blue/green459 - 4795006.0
Band 4 - green545 - 5655003.0
Band 5 - near infrared1230 – 12505008.0
Band 6 - mid-infrared1628 – 165250018
Band 7 - mid-infrared2105 - 215550018

Example NBR Plots Calculated for Post and Pre Fire Landsat Images

NBR - Post Cold Springs Fire using Landsat 8 data.
NBR - Post Cold Springs Fire using Landsat 8 data.

Difference NBR

The Normalized Burn Ratio is most powerful as a tool to better understand fire extent and severity when used after calculating the difference between pre and post fire conditions. This difference is best measured using data collected immediately before the fire and then immediately after the fire. NBR is less effective if time has passed and vegetation regrowth / regeneration has begun after the fire. Once vegetation regeneration has begun, the fire scar will begin to reflect a stronger signal in the NIR portion of the spectrum because healthy plants reflect strongly in the NIR portion due to the properties of chlorophyll).

For this reason, the NBR ratio works better in areas like the United States where plant regeneration is expected to occur more slowly. In areas like the tropics which are wet and characterized by rapid regrowth, NBR may be less effective.

To calculate the difference NBR, you subtract the post-fire NBR raster from the pre-fire NBR raster as follows:

NBR - US Forest Service.
difference NBR (dNBR) equation. Source Humboldt.edu

The classification table below can be used to classify the difference raster according to the severity of the burn.

SEVERITY LEVEL dNBR RANGE
Enhanced Regrowth < -.1
Unburned -.1 to +.1
Low Severity +.1 to +.27
Moderate Severity +.27 to +.66
High Severity > .66

How Severe is Severe?

It is important to keep in mind that that the classification table above is one quantitative interpretation of what the results of dNBR actually mean. The term “severity” is a qualitative term that could be quantified in different ways. For instance, who is to say that .5 couldn’t be representative of “high severity” vs .66?

As scientists, the best way to make sure your classification approaches represent what is actually happening on the ground in terms of fire severity is to check out the actual conditions on the ground. This process of confirming a value that you get from remote sensing data by checking it on the ground is called validation.

You can review more about ground validation as it applies to lidar data in the
chapter on uncertainty in remote sensing data.

NBR & Water - False Positives

The NBR index can be a powerful tool to identify pixels that have a high likelyhood or being “burned”. However it is important to know that this index is also sensitive to water and thus sometimes, pixels that are classified as “high severity” may actually be water. Because of this, it is important to mask out areas of water PRIOR to performing any quantitative analysis on the difference NBR results.

Leave a Comment