Before starting, make sure you understand these terms. They appear throughout all code blocks in this course.
| Term | Full Name | What it means in simple words |
|---|---|---|
| SAR | Synthetic Aperture Radar | An active microwave sensor capable of penetrating clouds and operating day or night to image Earth surfaces. |
| Backscatter | Radar Backscatter Coefficient | The proportion of microwave signal reflected back to the radar antenna, which drops significantly over smooth water surfaces. |
| VV Polarization | Vertical Send, Vertical Receive Polarization | A radar transmission mode sensitive to surface roughness, making it effective for detecting open surface water. |
| Speckle Noise | Granular Radar Speckle Noise | A salt-and-pepper noise inherent to coherent radar systems that must be smoothed using spatial filtering. |
| Change Detection | Bi-Temporal Change Detection | A method comparing pre-disaster and post-disaster imagery to isolate altered surface conditions such as flooding. |
| Permanent Water Mask | Baseline Hydrological Surface Mask | A spatial layer used to exclude regular lakes and rivers from newly inundated flood extent calculations. |
| Population Exposure | Spatial Demographic Vulnerability | The quantified count of people living within spatial boundaries directly impacted by environmental hazards. |
| Environmental Determinant | Environmental Determinant of Health | Physical surroundings, such as floodwaters or standing moisture, that elevate exposure risk to infectious diseases. |
| Waterborne Disease Risk Proxy | Spatial Risk Proxy for Waterborne Pathogens | An estimated risk index derived from inundated area proximity and human population density. |
| HAND | Height Above Nearest Drainage | A topographic normalized elevation model used to evaluate flood susceptibility relative to stream networks. |
| Spatial Autocorrelation | Tobler Spatial Autocorrelation | The statistical property where geographic features close to each other exhibit similar environmental risk values. |
| Ecological Fallacy | Spatial Aggregation Fallacy | An error in inference where individual-level health outcomes are assumed based solely on aggregated spatial data. |
Flooding events severely disrupt communities worldwide, contaminating water supplies and triggering outbreaks of waterborne and vector-borne diseases. Remote sensing using Synthetic Aperture Radar (SAR) provides cloud-free imagery to accurately map surface inundation across global flood-prone regions. By integrating Sentinel-1 SAR flood mapping with high-resolution population datasets, this course demonstrates how spatial data science can quantify human exposure and construct spatial health vulnerability proxies during major disaster events.
COPERNICUS/S1_GRDYou need two browser tabs open side by side throughout this course.
Course30_Global Flood Risk and Public Health Impact Assessment
The prompt is the core skill of this course. A good prompt includes the exact dataset ID, band names, study area coordinates, dates, preprocessing steps, and desired outputs.
Paste the following code into your GEE code editor and click Run. Read the beginner notes below to understand what each line does.
// 1. Define Geographic ROI (Sylhet Division, Bangladesh)
var roi = ee.Geometry.Polygon([
[[91.30, 24.30], [92.50, 24.30], [92.50, 25.20], [91.30, 25.20]]
]);
Map.centerObject(roi, 9);
Map.setOptions('HYBRID');
// 2. Load Sentinel-1 SAR Collection (VV Polarization, IW mode)
var s1 = ee.ImageCollection('COPERNICUS/S1_GRD')
.filterBounds(roi)
.filter(ee.Filter.eq('instrumentMode', 'IW'))
.filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV'))
.select('VV');
// 3. Define Temporal Windows (Pre-Flood vs Post-Flood 2022)
var preFlood = s1.filterDate('2022-04-15', '2022-05-15').mean().clip(roi);
var postFlood = s1.filterDate('2022-06-15', '2022-06-30').mean().clip(roi);
// 4. Speckle Filtering (3x3 Focal Mean)
var preFiltered = preFlood.focal_mean(30, 'circle', 'meters');
var postFiltered = postFlood.focal_mean(30, 'circle', 'meters');
// 5. Compute Inundation via Change Detection (Ratio/Difference)
var difference = postFiltered.subtract(preFiltered);
var floodThreshold = -3.5;
var rawFlood = difference.lt(floodThreshold);
// 6. Mask Permanent Water & Steep Slopes
var jrcWater = ee.Image('JRC/GSW1_4/GlobalSurfaceWater').select('occurrence');
var permanentWater = jrcWater.gt(80);
var srtm = ee.Image('USGS/SRTMGL1_003');
var slope = ee.Terrain.slope(srtm);
var steepTerrain = slope.gt(5);
var confirmedFlood = rawFlood.where(permanentWater, 0).where(steepTerrain, 0).selfMask();
// 7. Visualization
Map.addLayer(preFiltered, {min: -25, max: 0}, 'Pre-Flood Sentinel-1 (VV)', false);
Map.addLayer(postFiltered, {min: -25, max: 0}, 'Post-Flood Sentinel-1 (VV)', false);
Map.addLayer(confirmedFlood, {palette: ['darkblue']}, 'Extracted Flood Extent');
Add this block after the previous code. It continues the analysis with additional processing and visualization.
// 8. Load WorldPop Data (2020 Population Count)
var worldPop = ee.ImageCollection('WorldPop/GP/100m/pop')
.filterBounds(roi)
.filter(ee.Filter.eq('year', 2020))
.mosaic()
.clip(roi);
// 9. Calculate Exposed Population Density
var exposedPop = worldPop.updateMask(confirmedFlood);
// 10. Spatial Health Risk Proxy (Distance to Flood + Population Density)
// Proximity to standing floodwater increases waterborne risk exposure
var floodDistance = confirmedFlood.fastDistanceTransform(500).sqrt().multiply(30); // in meters
var proximityScore = ee.Image(1).subtract(floodDistance.divide(5000)).clamp(0, 1);
// Normalize Population Density (0-1 scale)
var popMax = 500; // threshold for high density per cell
var popScore = worldPop.divide(popMax).clamp(0, 1);
// Composite Risk Index = Proximity Weight (0.6) + Density Weight (0.4)
var healthRiskIndex = proximityScore.multiply(0.6).add(popScore.multiply(0.4)).updateMask(popScore.gt(0.01));
// 11. Compute Total Exposed Population Metric
var stats = exposedPop.reduceRegion({
reducer: ee.Reducer.sum(),
geometry: roi,
scale: 100,
maxPixels: 1e9
});
print('Estimated Total Population Exposed to Inundation:', stats.get('population'));
// 12. Visualization of Vulnerability & Risk
Map.addLayer(worldPop, {min: 0, max: 200, palette: ['white', 'yellow', 'orange', 'red']}, 'WorldPop Population', false);
Map.addLayer(exposedPop, {min: 0, max: 100, palette: ['purple', 'magenta']}, 'Exposed Population');
Map.addLayer(healthRiskIndex, {min: 0.2, max: 1.0, palette: ['blue', 'cyan', 'yellow', 'orange', 'red']}, 'Health Risk Exposure Index');
Add this block at the end of your script to export the final map as a GeoTIFF to your Google Drive. After clicking Run, go to the Tasks tab in GEE and click Run next to each export task.
// Export Flooded Area and Health Exposure Risk Map to Google Drive
Export.image.toDrive({
image: healthRiskIndex.toFloat(),
description: 'Sylhet_Flood_Health_Risk_2022',
folder: 'GEE_Health_Disasters',
fileNamePrefix: 'Sylhet_Health_Risk_Index_2022',
region: roi,
scale: 100,
crs: 'EPSG:4326',
maxPixels: 1e9
});
// Export Inundation Mask Raster
Export.image.toDrive({
image: confirmedFlood.toByte(),
description: 'Sylhet_Flood_Extent_2022',
folder: 'GEE_Health_Disasters',
fileNamePrefix: 'Sylhet_Inundation_Mask_2022',
region: roi,
scale: 30,
crs: 'EPSG:4326',
maxPixels: 1e9
});
Use DeepSeek to extend the script for each exercise below. Write a follow-up prompt describing what you want to add, then copy the generated code and paste it into your GEE script.
To get the best results from DeepSeek for GEE tasks, always include these elements in your prompts:
| Element | Example |
|---|---|
| Exact dataset ID | COPERNICUS/S1_GRD |
| Band names | "select band 'B4' for red, 'B8' for NIR" |
| Study area | "rectangle [-6.5, 33.0, -1.5, 36.0] North Morocco" |
| Date range | "filter from 2020-01-01 to 2023-12-31" |
| Output format | "print area in hectares, add a legend, export to Drive" |
| Error fixing | "The code gives error X. Please fix it." |
| Iteration | "Add a time series chart for each year 2018-2023" |