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 |
|---|---|---|
| MODIS | Moderate Resolution Imaging Spectroradiometer | A key instrument aboard the Terra (EOS AM) and Aqua (EOS PM) satellites, viewing the entire Earth's surface every 1 to 2 days. |
| Fire Radiative Power (FRP) | Fire Radiative Power | The rate of emitted radiative energy from a fire, a key indicator of fire intensity. |
| Active Fire Detection | Active Fire Detection | Identifying locations where fires are currently burning based on satellite observations. |
| GEE | Google Earth Engine | A cloud-based platform for planetary-scale geospatial analysis. |
| NDVI | Normalized Difference Vegetation Index | A simple graphical indicator that can be used to analyze remote sensing measurements, often from a space platform, and assess whether the target being observed contains live green vegetation. |
| EVI | Enhanced Vegetation Index | An 'optimized' vegetation index designed to enhance the vegetation signal with improved sensitivity in high biomass regions and improved vegetation monitoring through a de-coupling of the canopy background signal and a reduction in atmosphere influences. |
| LST | Land Surface Temperature | The radiative skin temperature of the land surface, a key factor in fire ignition. |
| Fuel Load | Fuel Load | The amount of combustible material available for a fire. |
| Topography | Topography | The shape and features of the land surface, including elevation and slope. |
| DeepSeek | DeepSeek LLM | A large language model used for code generation and analysis. |
| Classification | Classification | Categorizing pixels into different classes based on their characteristics. |
| Risk Map | Risk Map | A visual representation of the likelihood of a specific event occurring, in this case, a wildfire. |
Wildfires pose a significant threat to ecosystems and human populations. This course will guide you through the process of mapping wildfire risk using MODIS satellite data and the DeepSeek AI model within Google Earth Engine. You'll learn to analyze fire detections, vegetation indices, land surface temperature, and topography to create a comprehensive risk assessment.
MODIS/061/MCD14ML/C6_1You need two browser tabs open side by side throughout this course.
Course10_Wildfire Risk Mapping with MODIS and DeepSeek
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.
// Define the region of interest (Rif Mountains and Middle Atlas, Morocco)
var roi = ee.Geometry.Rectangle([-6, 32, -2, 35]);
// Filter MODIS active fire data for 2023
var fires = ee.ImageCollection('MODIS/061/MCD14ML/C6_1')
.filterDate('2023-01-01', '2023-12-31')
.filterBounds(roi);
// Function to mask out pixels with low confidence
var maskLowConfidence = function(image) {
return image.updateMask(image.select('confidence').gt(50));
};
// Apply the mask
vAR firesFiltered = fires.map(maskLowConfidence);
//Mosaic the fire collection and select the FRP band
var fire_frp = firesFiltered.mosaic().select('frp');
Add this block after the previous code. It continues the analysis with additional processing and visualization.
// Function to calculate NDVI
var calculateNDVI = function(image) {
return image.normalizedDifference(['Nir', 'Red']).rename('NDVI');
};
// Function to calculate EVI
var calculateEVI = function(image) {
return image.expression(
'2.5 * ((NIR - RED) / (NIR + 6 * RED - 7.5 * BLUE + 1))', {
'NIR': image.select('Nir'),
'RED': image.select('Red'),
'BLUE': image.select('Blue')
}).rename('EVI');
};
// Load MODIS surface reflectance data
var modisSR = ee.ImageCollection('MODIS/061/MOD09GA/006')
.filterDate('2023-01-01', '2023-12-31')
.filterBounds(roi);
// Apply scaling factors and rename bands
var modisSRScaled = modisSR.map(function(image) {
return image.multiply(0.0001).select('sur_refl_b01', 'sur_refl_b02', 'sur_refl_b04').rename('Red', 'Nir', 'Blue').copyProperties(image, ['system:time_start']);
});
// Calculate NDVI and EVI
var ndvi = modisSRScaled.map(calculateNDVI).mosaic();
var evi = modisSRScaled.map(calculateEVI).mosaic();
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 the risk map
Export.image.toDrive({
image: riskMap,
description: 'Wildfire_Risk_Map_Morocco_2023',
folder: 'GEE_Exports',
region: roi,
scale: 30, // Adjust scale as needed
maxPixels: 1e13
});
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 | MODIS/061/MCD14ML/C6_1 |
| 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" |