A Comprehensive Guide to NDVI Image Analysis and Mapping in Google Earth Engine
Google Earth Engine is a powerful cloud computing platform that enables advanced analysis of satellite imagery and geospatial data at a global scale. One of the most commonly used analyses in Earth Engine is calculating the Normalized Difference Vegetation Index, or NDVI. NDVI is a simple yet effective way to quantify vegetation greenness and assess land cover using multispectral satellite imagery.
In this in-depth tutorial, we‘ll walk through how to perform NDVI analysis and mapping in Google Earth Engine. You‘ll learn what NDVI is, how to calculate it, visualize and interpret the results, and use NDVI for various remote sensing applications. By the end, you‘ll have the knowledge and skills to utilize this essential vegetation index for your own geospatial projects. Let‘s get started!
What is NDVI?
NDVI stands for Normalized Difference Vegetation Index. It is a standardized index that allows you to generate an image displaying greenness, or relative biomass. This index takes advantage of the contrast between the characteristics of two bands from a multispectral sensor—the chlorophyll pigment absorptions in the red band and the high reflectivity of plant materials in the near-infrared (NIR) band.
The NDVI is calculated from these individual measurements as follows:
NDVI = (NIR — Red) / (NIR + Red)
Where NIR is the near-infrared band and Red is the red band. NDVI values range from -1.0 to 1.0. Areas of barren rock, sand, or snow usually show very low NDVI values (for example, 0.1 or less). Sparse vegetation such as shrubs and grasslands or senescing crops may result in moderate NDVI values (approximately 0.2 to 0.5). High NDVI values (approximately 0.6 to 0.9) correspond to dense vegetation such as temperate and tropical forests or crops at their peak growth stage.
Because NDVI is a normalized index, it allows for meaningful comparisons of seasonal and inter-annual changes in vegetation growth and activity. This makes NDVI an invaluable tool for everything from precision agriculture and forest monitoring to measuring the impacts of climate change on ecosystems.
Analyzing NDVI in Google Earth Engine
Earth Engine provides access to numerous satellite image collections that you can use to calculate NDVI, including the popular Landsat and MODIS archives. For this tutorial, we‘ll use Landsat 8 data to perform our analysis. Here are the step-by-step instructions:
Step 1: Define study area
The first step is to define your area of interest. You can do this by drawing a polygon or importing an asset like a shapefile boundary. For this example, we‘ll focus on an agricultural region in Brazil.
Step 2: Load and filter image collection
Next, you‘ll load the Landsat 8 TOA image collection and filter it to your desired time period and study area bounds. You may also apply additional filters like maximum cloud cover percentage. It‘s often helpful to take a composite or median of multiple images to minimize issues like clouds and shadows.
// Load Landsat 8 TOA collection
var l8 = ee.ImageCollection(‘LANDSAT/LC08/C01/T1_TOA‘)
.filterDate(‘2020-01-01‘, ‘2020-12-31‘)
.filterBounds(roi)
.filter(ee.Filter.lt(‘CLOUD_COVER‘, 20));
// Create a median composite
var composite = l8.median().clip(roi);
Step 3: Calculate NDVI
To calculate NDVI, you‘ll use the NIR and red bands which are bands 5 and 4 respectively in Landsat 8 imagery. Remember the NDVI formula takes the difference between the NIR and red bands divided by their sum.
// Calculate NDVI
var nir = composite.select(‘B5‘);
var red = composite.select(‘B4‘);
var ndvi = nir.subtract(red).divide(nir.add(red)).rename(‘NDVI‘);
Step 4: Visualize results
Let‘s visualize the raw NDVI results by adding the image to the map. We‘ll use a palette color scheme that assigns green tones to high NDVI values and browns to low values.
// Styling
var ndviParams = {min: -1, max: 1, palette: [‘brown‘, ‘yellow‘, ‘green‘]};
// Add NDVI layer to map
Map.addLayer(ndvi, ndviParams, ‘NDVI‘);
Step 5: Interpret NDVI
NDVI results are relatively straightforward to interpret visually. Photosynthetically active vegetation shows up as bright green, whereas areas with little or no vegetation are tan to brown. An advantage of NDVI is that it partially compensates for changes in illumination conditions (e.g. from terrain or weather), surface slopes, and viewing aspects.
For a more quantitative assessment, you can check pixel values using the Inspector tool. As mentioned earlier, NDVI values range from -1 to 1 with common ranges being:
- < 0.1: Barren areas, rock, sand, snow
- 0.2 to 0.5: Shrubs, grasslands, senescing crops
-
0.6: Dense vegetation, tropical forests, peak-growth crops
You may also want to calculate summary statistics over your area of interest like mean and standard deviation:
// Calculate mean and standard deviation
var mean = ndvi.reduceRegion({
reducer: ee.Reducer.mean(),
geometry: roi,
scale: 30
}).get(‘NDVI‘);
var stdDev = ndvi.reduceRegion({
reducer: ee.Reducer.stdDev(),
geometry: roi,
scale: 30
}).get(‘NDVI‘);
print(‘NDVI mean:‘, mean);
print(‘NDVI std dev:‘, stdDev);
Step 6: Classify NDVI
For further analysis and visualization, you may want to classify the raw NDVI values into discrete categories. This provides a simplified vegetation/land cover map. Here‘s an example of breaking NDVI into 5 classes:
var ndviClass = ee.Image(1)
.where(ndvi.lt(0), 0)
.where(ndvi.gte(0).and(ndvi.lt(0.2)), 1)
.where(ndvi.gte(0.2).and(ndvi.lt(0.4)), 2)
.where(ndvi.gte(0.4).and(ndvi.lt(0.6)), 3)
.where(ndvi.gte(0.6), 4);
// Styling
var classParams = {
min: 0,
max: 4,
palette: [‘brown‘, ‘yellow‘, ‘yellowgreen‘, ‘green‘, ‘darkgreen‘]
};
Map.addLayer(ndviClass, classParams, ‘NDVI Classes‘);
Applications of NDVI
NDVI is an invaluable tool for numerous earth science applications, such as:
Agriculture: NDVI allows farmers and researchers to quantify crop health, growth stage, and yield potential. It is key for precision agriculture.
Forestry: NDVI is used to monitor forest growth, disturbance, and recovery. It can track things like deforestation, wildfire damage, and insect infestations.
Ecology: As a measure of vegetation productivity, NDVI correlates with species richness and biodiversity. It is used to characterize wildlife habitat.
Drought monitoring: Relative to long-term average NDVI values, a drop in NDVI can indicate a drought, especially if sustained over a growing season.
Climate change: Trends in NDVI over time relate to climate factors like temperature and precipitation and are used to study climate change impacts on vegetation.
Land cover mapping: Combining current and historical NDVI data can be used to map land cover and quantify change over time, such as urban expansion or wetland loss.
Tips for Effective NDVI Analysis
To get the most out of your NDVI analysis, keep the following tips in mind:
-
Use surface reflectance (SR) imagery when possible. Compared to top-of-atmosphere (TOA) data, SR data is atmospherically corrected which can improve NDVI results.
-
Be aware of seasonal effects. NDVI values will vary significantly between seasons, especially in temperate regions. Be sure to compare data from the same time of year.
-
Watch out for anomalies. Clouds, cloud shadows, and snow can skew NDVI results. Use quality bands and masks to minimize these issues.
-
Consider the limitations. NDVI can saturate in densely vegetated areas and be thrown off by exposed soil. It is not ideal for sparsely vegetated drylands or areas with significant background soil influence.
-
Ground truth when possible. Collecting on-the-ground vegetation measurements is the best way to validate your NDVI analysis and classification. High resolution aerial/drone imagery can also help.
Exporting and Sharing
Finally, you‘ll likely want to export your NDVI results for further analysis or sharing with others. Earth Engine makes this easy. You can export images, tables, and video animations. Images can be exported in GeoTIFF or other common formats:
Export.image.toDrive({
image: ndvi,
description: ‘NDVI_2020_Brazil‘,
folder: ‘EarthEngine‘,
fileNamePrefix: ‘NDVI_2020_Brazil‘,
region: roi,
scale: 30
});
For interactive data visualization and sharing, you can also publish maps using Earth Engine Apps. See the Publishing Apps tutorial to learn more.
Keep Learning
NDVI is just the start when it comes to vegetation analysis in Earth Engine. There are numerous other spectral indices to try like EVI, SAVI, MSAVI, and more. Combining NDVI with other datasets in Earth Engine like terrain, climate, and land cover can further enrich your geospatial analysis.
To keep developing your skills, check out the official Earth Engine tutorials and documentation. The Earth Engine community is also a great resource—you can find tons of code examples and get help from other users on Stack Exchange and the Developers Forum.
The possibilities are endless with Earth Engine. All it takes is an idea and some JavaScript skills. As you‘ve seen in this tutorial, in just a few lines of code you can unlock powerful geospatial insights at a planetary scale. So open up the Code Editor and start exploring. Happy mapping!