Google Earth Engine Tutorial: Download NDVI Images from Landsat 8
Credit: Youtube Channel “Terra Spatial, Step-by-step guide on downloading NDVI images derived from Landsat 8 data for any location.”
You can see all the tutorials from here: Techgeo Academy.
Google Earth Engine (GEE) is a powerful platform for planetary-scale environmental data analysis. One of its most common applications is extracting vegetation indices like the Normalized Difference Vegetation Index (NDVI) from satellite imagery. Landsat 8 is a widely used dataset for this purpose due to its high spatial resolution and spectral bands. Below is a step-by-step guide to downloading NDVI images from Landsat 8 using GEE.
Getting Started
To begin, you must have a Google Earth Engine account. Once registered, access the GEE Code Editor. This environment allows you to write, run, and export scripts.
Steps to Download NDVI Images from Landsat 8
1. Load the Landsat 8 Dataset
First, load the Landsat 8 Surface Reflectance dataset, which includes the necessary bands for NDVI calculation (NIR and Red).
var dataset = ee.ImageCollection('LANDSAT/LC08/C02/T1_L2');
2. Filter the Dataset
Define a date range and location to filter the data. Replace the geometry with your study area or use a predefined one.
var filtered = dataset.filterDate('2023-01-01', '2023-12-31').filterBounds(geometry);
3. Calculate NDVI
NDVI is calculated using the formula: (NIR – Red) / (NIR + Red). Use the normalizedDifference
function in GEE.
var ndvi = filtered.select(['SR_B6', 'SR_B4']).map(function(image) { return image.normalizedDifference(['SR_B6', 'SR_B4']).rename('NDVI'); });
4. Export the NDVI Image
Select the most recent image and export it as a GeoTIFF using the Export.image.toDrive
function.
var image = ndvi.first();
Export.image.toDrive({
image: image,
description: 'NDVI_Landsat8',
folder: 'GEE_Exports',
fileNamePrefix: 'NDVI_Landsat8',
region: geometry,
crs: 'EPSG:4326',
scale: 30,
maxPixels: 1e10
});
Example Code
// Load Landsat 8 dataset
var dataset = ee.ImageCollection('LANDSAT/LC08/C02/T1_L2');
// Define geometry (e.g., a polygon around your area of interest)
var geometry = ee.Geometry.Rectangle([left, bottom, right, top]);
// Filter by date and location
var filtered = dataset.filterDate('2023-01-01', '2023-12-31').filterBounds(geometry);
// Calculate NDVI
var ndvi = filtered.select(['SR_B6', 'SR_B4']).map(function(image) {
return image.normalizedDifference(['SR_B6', 'SR_B4']).rename('NDVI');
});
// Export the first image in the collection
var image = ndvi.first();
Export.image.toDrive({
image: image,
description: 'NDVI_Landsat8',
folder: 'GEE_Exports',
fileNamePrefix: 'NDVI_Landsat8',
region: geometry,
crs: 'EPSG:4326',
scale: 30,
maxPixels: 1e10
});
FAQ
What is NDVI and why is it important?
NDVI (Normalized Difference Vegetation Index) measures vegetation health by comparing near-infrared and red light reflectance. It is used in agriculture, ecology, and environmental monitoring.
What parameters are required for the export?
The export requires the image
to be exported, a description
for the task, a folder
in Google Drive, a fileNamePrefix
, region
or geometry, crs
(coordinate reference system), scale
(resolution in meters), and maxPixels
to handle large areas.
Can I export NDVI in other formats besides GeoTIFF?
Yes, GEE allows exporting to formats like JPEG, PNG, or CSV, but GeoTIFF is recommended for GIS applications due to its geospatial metadata.
Why use Landsat 8 for NDVI?
Landsat 8 offers 30-meter resolution, wide temporal coverage, and free access to surface reflectance data, making it ideal for NDVI analysis at a regional scale.
What if the export takes too long?
Ensure the maxPixels
parameter is set to a large enough value. Adjust the scale
or region
if needed to reduce processing time.