Google Earth Engine Tutorial: Four-Decade NDVI Analysis with Landsat
Credit: Youtube Channel “Terra Spatial, Comprehensive analysis of NDVI trends over four decades using the entire Landsat satellite series.”
You can see all the tutorials from here: Techgeo Academy.
Introduction to NDVI Analysis with Landsat in Google Earth Engine
Normalized Difference Vegetation Index (NDVI) is a critical tool for assessing vegetation health and changes over time. This tutorial demonstrates how to analyze four-decade trends in NDVI using Landsat satellite imagery through Google Earth Engine (GEE), a cloud-based platform that allows processing of large geospatial datasets.
Step 1: Setting Up Google Earth Engine
Ensure you have a Google account and access to GEE. Open the Code Editor at code.earthengine.google.com. Authenticate by clicking Run and following the prompts. Once authenticated, you can proceed to load and process datasets.
Step 2: Loading and Filtering Landsat Data
Landsat satellites have provided continuous records since 1984. We’ll use Landsat 5, 7, and 8 for this analysis to cover the entire four-decade span. The code below loads the datasets and filters them by date and cloud cover:
var dataset = ee.ImageCollection('LANDSAT/LT05/C02/T1_L2')
.merge(ee.ImageCollection('LANDSAT/LE07/C02/T1_L2'))
.merge(ee.ImageCollection('LANDSAT/LC08/C02/T1_L2'))
.filterDate('1984-01-01', '2024-01-01')
.filter(ee.Filter.lt('CLOUD_COVER', 20));
Step 3: Calculating NDVI
NDVI is calculated using the formula: (NIR – Red)/(NIR + Red). Landsat collections provide the necessary bands (SR_B7 for NIR and SR_B4 for Red). The following code computes NDVI for each image:
var ndvi = dataset.map(function(image) {
return image
.select(['SR_B7', 'SR_B4'])
.reduce(ee.Reducer.linearRegression(2, 1))
.select(['reduction']);
});
Step 4: Visualizing NDVI Trends
To visualize trends, median composite images can be created for specific time intervals (e.g., annual or decadal). Hereβs an example of creating annual composites and displaying them on the map:
var annualComposites = ee.ImageCollection.fromImages(
ee.List.sequence(1984, 2023, 1).map(function(year) {
return dataset.filter(ee.Filter.calendarRange(year, year, 'year'))
.median();
})
);
Map.addLayer(annualComposites, {bands: ['SR_B7', 'SR_B4', 'SR_B3'], min: 0, max: 3000}, 'NDVI Composite');
Step 5: Time Series Analysis and Visualization
For a detailed time series, use the chart.image.series function to plot NDVI changes over time. This example extracts time series data for a specific region:
var chart = ui.Chart.image.series(annualComposites, roi, ee.Reducer.mean(), 30);
chart.setOptions({title: 'NDVI Trend Over Four Decades'});
print(chart);
Step 6: Analyzing Vegetation Changes
To identify long-term trends, apply statistical functions like linear regression across the time series. This code calculates a trend map:
var trend = annualComposites.select(['reduction']).reduce(ee.Reducer.linearRegression(2, 1));
var slope = ee.Image(trend.select('coefficients')).select('coefficients_0');
Map.addLayer(slope, {min: -0.1, max: 0.1, palette: ['blue', 'white', 'green']}, 'NDVI Trend');
FAQ
What are the challenges of analyzing four-decade NDVI data?
Consistency in data processing, cloud cover removal, and handling sensor calibration differences across Landsat missions are key challenges. GEEβs built-in tools help standardize these processes.
Which Landsat sensors are compatible with this analysis?
Landsat 5 (TM), 7 (ETM+), and 8 (OLI) datasets support NDVI calculation. Landsat 9 (OLI-2) is also compatible but may not be required for the full four-decade span.
How can I improve the accuracy of NDVI results?
Use surface reflectance data (SR) instead of raw digital numbers. Apply cloud masking and ensure atmospheric correction to reduce noise.
Can I export the NDVI results for local analysis?
Yes. Use Export.image to save outputs as GeoTIFF or other formats. Define the export region, scale, and format in the code.
Why do the results vary between Landsat missions?
Different sensors have varying band characteristics and radiometric resolutions. Calibration and normalization steps are necessary to align datasets across missions.







