Google Earth Engine Tutorial: Analyze River Water Levels with SWOT
Credit: Youtube Channel “Terra Spatial, Guide on analyzing river water levels using SWOT satellite data for hydrological monitoring.”
You can see all the tutorials from here: Techgeo Academy.
Google Earth Engine Tutorial: Analyze River Water Levels with SWOT
This tutorial demonstrates how to use Google Earth Engine (GEE) to analyze river water levels using data from the Surface Water and Ocean Topography (SWOT) mission. SWOT provides high-resolution measurements of water surface elevation, making it a powerful tool for hydrological studies. Follow these steps to process and visualize SWOT data in GEE.
Step 1: Access SWOT Data in Google Earth Engine
To load SWOT data, first ensure you have a GEE account and activate its API. Use the following code:
var swot = ee.ImageCollection("NASA/SWOT_L2_LR_HR");
This dataset includes water surface elevation, river width, and flow velocity. Filter it by region and date to focus on your study area.
Step 2: Select and Filter a Study Area
Create a geometry for your river of interest. For example:
var region = ee.Geometry.Rectangle([ -120, 40, -110, 45 ]);
Apply a date range and select relevant bands:
var filtered = swot.filterDate('2023-01-01', '2023-12-31')
.filterBounds(region)
.select(['water_surface_elevation', 'river_width']);
Step 3: Visualize Water Levels
Map water surface elevation to visualize changes:
Map.setCenter(-115, 42, 8);
var elevationVis = {min: 0, max: 200, palette: ['blue', 'green', 'red']};
Map.addLayer(filtered.select('water_surface_elevation'), elevationVis, 'Water Surface Elevation');
Use the ee.Image.visualize()
function to customize color palettes.
Step 4: Analyze Time Series Data
Extract water elevation values for a specific point using ee.Image.reduceRegion()
.
var point = ee.Geometry.Point([-115, 42]);
var timeSeries = filtered.map(function(image) {
return image.select('water_surface_elevation').reduceRegion(ee.Reducer.first(), point);
});
Convert the result to a JavaScript dictionary for further analysis:
var data = timeSeries.getRegion(point, 100);
print(data);
Step 5: Calculate Elevation Trends
Use the reduce(ee.Reducer.linearFit())
function to identify trends over time:
var trend = filtered.select('water_surface_elevation').
reduce(ee.Reducer.linearFit());
Map.addLayer(trend, {min: -1, max: 1}, 'Elevation Trend');
This highlights rising or falling water levels across the study area.
Step 6: Export Results
Export data for further analysis or sharing:
Export.image.toDrive({
image: filtered.select('water_surface_elevation'),
description: 'SWOT_Water_Elevation',
folder: 'GEE_Exports',
fileNamePrefix: 'river_levels',
region: region,
scale: 30,
maxPixels: 1e10
});
FAQ
What is SWOT data in Google Earth Engine?
SWOT (Surface Water and Ocean Topography) is a satellite mission providing global measurements of water surface elevation, river width, and floodplain dynamics. GEE offers access to SWOT datasets for large-scale hydrological analysis.
Can SWOT data be used for real-time monitoring?
SWOT data is primarily based on satellite observations and is not real-time. However, it provides frequent updates, enabling analysis of temporal trends in water levels.
How to handle missing or invalid SWOT data?
Use mask()
or where()
functions to filter out invalid pixels. Check the swot.mask()
band to identify areas with quality issues.
Is SWOT data compatible with other GEE datasets?
Yes, SWOT data can be combined with other datasets like Landsat or Sentinel-1 for integrated watershed analysis or flood risk modeling.
What tools can help visualize SWOT results in GEE?
The GEE Code Editor’s map interface allows direct visualization. Use ui.Chart.image.histogram()
to plot elevation distributions or ui.Chart.image.series()
for time series analysis.