Using Google Earth Engine for Remote Sensing
Table of contents
- Getting Started with Google Earth Engine
- Key Concepts
- Example Workflow
- 1. Define the Study Area
- 2. Define the Function to Calculate NDVI
- 3. Define Date Ranges for Drought and Non-Drought Years
- 4. Load Landsat 8 Imagery for Both Years
- 5. Calculate NDVI for Both Years
- 6. Visualize NDVI on the Map
- 7. Export NDVI Results
- 8. Additional Visualization - False Color Composite
- 9. Listing Image IDs in the Collection
Google Earth Engine (GEE) is a powerful cloud-based platform for planetary-scale environmental data analysis. This guide will walk you through using GEE to analyze NDVI (Normalized Difference Vegetation Index) for drought and non-drought years in the Palouse region.
Getting Started with Google Earth Engine
Sign Up and Access:
To use GEE, you need a Google account. Sign up for GEE here.
Access the GEE Code Editor via https://code.earthengine.google.com/.
Interface Overview:
- The GEE Code Editor includes sections for writing and running JavaScript code, an interactive map for visualization, and various panels for asset management, output display, and error logging.
โGet Started with Earth Engineโ*โ*Source
Key Concepts
Datasets:
- GEE hosts a variety of datasets, including Landsat, Sentinel, MODIS, and more. These datasets cover a range of applications from land cover and land use analysis to climate and environmental monitoring.
Scripting with JavaScript:
- GEE uses JavaScript for scripting. Users write scripts to process and analyze geospatial data. Python can also be used via the Earth Engine Python API for more complex integrations.
Filtering and Visualization:
Filtering: Select specific datasets, time ranges, and geographic areas using methods like
.filterDate()
,.filterBounds()
, etc.Visualization: Use
.addLayer()
to display data on the map.
Example Workflow
Here's a step-by-step guide to analyzing NDVI for the Palouse region during drought and non-drought years:
1. Define the Study Area
// Define the study area (Palouse region)
var studyArea = ee.Geometry.Polygon([
[-117.5, 46.5],
[-116.5, 46.5],
[-116.5, 47.5],
[-117.5, 47.5],
[-117.5, 46.5]
]);
2. Define the Function to Calculate NDVI
// Define a function to calculate NDVI
function calculateNDVI(image) {
var ndvi = image.normalizedDifference(['B5', 'B4']).rename('NDVI');
return ndvi;
}
3. Define Date Ranges for Drought and Non-Drought Years
// Define the date ranges
var droughtYear = ee.DateRange('2015-06-01', '2015-09-30');
var nonDroughtYear = ee.DateRange('2014-06-01', '2014-09-30');
4. Load Landsat 8 Imagery for Both Years
// Load Landsat 8 imagery for the drought year
var droughtImages = ee.ImageCollection('LANDSAT/LC08/C02/T1')
.filterBounds(studyArea)
.filterDate(droughtYear)
.sort('CLOUD_COVER');
// Load Landsat 8 imagery for the non-drought year
var nonDroughtImages = ee.ImageCollection('LANDSAT/LC08/C02/T1')
.filterBounds(studyArea)
.filterDate(nonDroughtYear)
.sort('CLOUD_COVER');
5. Calculate NDVI for Both Years
// Calculate NDVI for the drought year
var ndviDrought = droughtImages.map(calculateNDVI).median();
// Calculate NDVI for the non-drought year
var ndviNonDrought = nonDroughtImages.map(calculateNDVI).median();
6. Visualize NDVI on the Map
// Visualize NDVI on the map
var visParams = {
palette: ['red', 'yellow', 'green'], // Red to green palette
min: -1,
max: 1
};
Map.centerObject(studyArea, 9);
Map.addLayer(ndviDrought, visParams, 'NDVI Drought Year');
Map.addLayer(ndviNonDrought, visParams, 'NDVI Non-Drought Year');
7. Export NDVI Results
// Export NDVI Drought Year
Export.image.toDrive({
image: ndviDrought.toFloat(),
description: 'NDVI_Drought_Year',
scale: 30, // Adjust the scale as needed
region: studyArea,
folder: 'GEE', // Specify your folder in Google Drive
maxPixels: 1e10 // Adjust the maxPixels as needed
});
// Export NDVI Non-Drought Year
Export.image.toDrive({
image: ndviNonDrought.toFloat(),
description: 'NDVI_Non_Drought_Year',
scale: 30, // Adjust the scale as needed
region: studyArea,
folder: 'GEE', // Specify your folder in Google Drive
maxPixels: 1e10 // Adjust the maxPixels as needed
});
8. Additional Visualization - False Color Composite
// Load an image for false color composite
var image = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_043027_20140802');
// Define the visualization parameters
var vizParams = {
bands: ['B5', 'B4', 'B3'],
min: 0,
max: 0.5,
gamma: [0.95, 1.1, 1]
};
// Center the map and display the image
Map.addLayer(image, vizParams, 'False Color Composite');
9. Listing Image IDs in the Collection
// Load an image collection
var imageCollection = ee.ImageCollection('LANDSAT/LC08/C02/T1')
.filterBounds(studyArea)
.filterDate(nonDroughtYear)
.sort('CLOUD_COVER');
// Get the image IDs in the collection
var imageIDs = imageCollection.aggregate_array('system:index');
// Print the image IDs
print('Image IDs:', imageIDs);
Subscribe to my newsletter
Read articles from Shashwot Niraula directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Shashwot Niraula
Shashwot Niraula
๐ Greetings! I'm Shashwot, an enthusiastic undergraduate at the University of Idaho, actively pursuing a Bachelor's degree in Computer Science with a specialized emphasis on GIS and Remote Sensing, complemented by a keen interest in Machine Learning and AI. ๐ญ Currently, I am in search of a Summer 2024 Internship opportunity within the realm of Computer Science and GIS. ๐ค: The question that's been circulating lately is, "Why the combination of GIS and Remote Sensing with Computer Science?" My response stems from my exposure to this field during a previous internship focused on geo-tech. To deepen my understanding, I am undertaking relevant certificate courses at university. I aspire to leverage my computer science skills by integrating them with geo-tech because it represents a burgeoning domain with substantial potential. ๐๐ฐ๏ธ๐ฅ๏ธ