Google Earth Engine Tutorial: Analyze Lake Shoreline Changes
Credit: Youtube Channel “Terra Spatial, Tutorial on detecting and analyzing lake shoreline changes from 2016 to 2023 using Sentinel-2A imagery.”
You can see all the tutorials from here: Techgeo Academy.
Google Earth Engine (GEE) is a powerful platform for analyzing environmental changes. This tutorial will guide you through the process of analyzing lake shoreline changes using GEE, leveraging satellite imagery and time-series analysis. By the end, you’ll have a script to monitor and visualize shifts in lake boundaries over time.
Step 1: Set Up Your Environment
Before starting, ensure you have a Google account and access to the Google Earth Engine Code Editor. Log in to https://code.earthengine.google.com, then open the Code Editor.
To begin, load the GEE library in your script:
var ee = require('ee'); ee.Authenticate();
Run the script to authorize your account. Once authenticated, you’re ready to proceed.
Step 2: Define the Study Area and Time Range
Identify the lake and define its boundaries. For example:
var lakeRegion = ee.FeatureCollection('FAO/GAUL_SYM/2015');
var selectedLake = lakeRegion.filter(ee.Filter.eq('ADM0_NAME', 'Lake Superior'));
Adjust the region selection based on your specific lake. Define the time range for analysis, such as the past 20 years:
var startDate = '2000-01-01';
var endDate = '2020-12-31';
Step 3: Load and Filter Satellite Data
Select a satellite dataset, such as Landsat 8 or Sentinel-2, and filter imagery for the defined time and region:
var dataset = ee.ImageCollection("LANDSAT/LC08/C01/T1_SR")
.filterDate(startDate, endDate)
.filterBounds(selectedLake);
This example uses Landsat 8 Surface Reflectance data. Replace with other datasets if needed.
Step 4: Compute a Water Index
Use the Normalized Difference Water Index (NDWI) to identify water bodies:
var ndwi = dataset.map(function(image) {
return image.select(['SRB3', 'SRB4']).reduce(ee.Reducer.mean())
.multiply(10000)
.rename('NDWI');
});
NDWI is calculated as (NIR – SWIR) / (NIR + SWIR). Adjust bands based on the satellite sensor.
Step 5: Create a Shoreline Mask
Generate a water mask by applying a threshold to the NDWI values:
var waterMask = ndwi.map(function(image) {
return image.select('NDWI').gt(0.3);
});
Change the threshold value (e.g., 0.3) based on your lake’s characteristics. This helps isolate water pixels.
Step 6: Time-Series Analysis and Visualization
Aggregate the mask to compute the lake’s extent over time:
var shorelineAnalysis = waterMask.select('NDWI').median();
Map.addLayer(shorelineAnalysis, {palette: ['blue'], max: 1}, 'Shoreline Change');
Export the analysis for further use with:
Export.image.toDrive({
image: shorelineAnalysis,
description: 'LakeShorelineAnalysis',
folder: 'GEE_Exports',
fileName: 'shoreline_mask',
region: selectedLake.geometry(),
scale: 30,
maxPixels: 1e10
});
Step 7: Monitor Annual Changes
Create a time series by iterating over years and calculating the water area:
var years = ee.List.sequence(2000, 2020);
var yearlyStats = years.map(function(y) {
var yearImage = dataset.filter(ee.Filter.calendarDate(y, 'year')).median();
var waterArea = yearImage.select('NDWI').gt(0.3).reduce(ee.Reducer.sum());
return ee.Feature(null, {year: y, waterArea: waterArea.get('NDWI')});
});
Visualize the results using the Chart API or export to CSV for analysis.
FAQ
What satellite data is best for shoreline analysis?
High-resolution data like Landsat 8 or Sentinel-2 works well, but the choice depends on your area’s resolution and temporal coverage requirements.
How accurate are shoreline changes detected with GEE?
Accuracy depends on sensor resolution, cloud cover, and thresholding. Use high-quality data and refine the water index for better results.
Can I analyze changes for multiple lakes at once?
Yes, by modifying the feature collection to include multiple lakes and running the analysis iteratively.
Is GEE free to use for this analysis?
Yes, GEE provides free access to large datasets and computational resources for environmental research.
What if my lake is affected by seasonal variations?
Use multi-temporal composites (e.g., median or mean) to reduce noise, or filter images by season to isolate specific periods.