Practical Course 10

Wildfire Risk Mapping with MODIS and DeepSeek

Learn to map wildfire risk using satellite data and AI to identify vulnerable areas.
North Morocco ~2 hours Master - Climate Change and GeoAI
Dataset: MODIS/061/MCD14ML/C6_1 MODIS Collection 6.1 Fire Detections

📖 Key Terms for Beginners

Before starting, make sure you understand these terms. They appear throughout all code blocks in this course.

TermFull NameWhat it means in simple words
MODISModerate Resolution Imaging SpectroradiometerA 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 PowerThe rate of emitted radiative energy from a fire, a key indicator of fire intensity.
Active Fire DetectionActive Fire DetectionIdentifying locations where fires are currently burning based on satellite observations.
GEEGoogle Earth EngineA cloud-based platform for planetary-scale geospatial analysis.
NDVINormalized Difference Vegetation IndexA 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.
EVIEnhanced Vegetation IndexAn '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.
LSTLand Surface TemperatureThe radiative skin temperature of the land surface, a key factor in fire ignition.
Fuel LoadFuel LoadThe amount of combustible material available for a fire.
TopographyTopographyThe shape and features of the land surface, including elevation and slope.
DeepSeekDeepSeek LLMA large language model used for code generation and analysis.
ClassificationClassificationCategorizing pixels into different classes based on their characteristics.
Risk MapRisk MapA visual representation of the likelihood of a specific event occurring, in this case, a wildfire.

Contents

  1. Introduction to Wildfire Risk
  2. Understanding MODIS Fire Data
  3. Accessing Data in Google Earth Engine
  4. Calculating Vegetation Indices
  5. Land Surface Temperature Analysis
  6. Topographic Data Integration
  7. Generating DeepSeek Prompt
  8. Creating a Wildfire Risk Map
  9. Accuracy Assessment
  10. Exporting and Sharing Results
1
Introduction
10 min

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.

GEE Asset ID
MODIS/061/MCD14ML/C6_1
Dataset Name
MODIS Collection 6.1 Fire Detections
Study Area
North Morocco
AI Tool
DeepSeek (free, no API key needed)
🌍
What you will build: By the end of this course you will have a working GEE script that analyzes Wildfire Risk Mapping with MODIS and DeepSeek, computes statistics, visualizes results on an interactive map, and exports data to Google Drive.

2
Setup: GEE + DeepSeek
5 min

You need two browser tabs open side by side throughout this course.

1
Open chat.deepseek.com -- free account, no API key needed
2
Open code.earthengine.google.com in a second tab
3
Create a new GEE script named Course10_Wildfire Risk Mapping with MODIS and DeepSeek
💡
Workflow: Write a prompt in DeepSeek describing your task with exact dataset IDs and requirements. Copy the generated GEE JavaScript. Paste into GEE code editor. Click Run. Inspect results. Iterate.

3
Crafting the DeepSeek Prompt
15 min

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.

📋 Main Prompt -- copy and paste this into DeepSeek
Generate a Google Earth Engine JavaScript code to create a wildfire risk map for the Rif Mountains and Middle Atlas in North Morocco for the year 2023. Use MODIS active fire data (MODIS/061/MCD14ML/C6_1), calculate NDVI and EVI using MODIS surface reflectance data (MODIS/061/MOD09GA/006), and incorporate elevation data (USGS/SRTMGL1_003). Weight FRP (band 'frp') as 0.4, NDVI as 0.2, EVI as 0.2, LST (MODIS/061/MOD11A1/006, band 'LST_Day_1km') as 0.1 and elevation as 0.1. Classify the risk into low, medium, and high categories based on the calculated risk score. Display the risk map with appropriate color coding and a legend. Provide comments explaining each step in the code. Print the URL to share the map.
✨
After pasting the prompt: Wait 20-30 seconds for DeepSeek to generate the full GEE script. Copy the entire code block it produces. If the output is cut short, type "Continue the code" to get the rest.

4
Import and Filter MODIS Fire Data
10 min

Paste the following code into your GEE code editor and click Run. Read the beginner notes below to understand what each line does.

Import and Filter MODIS Fire Data
// 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');
🔑
Beginner note: This code block imports the MODIS active fire data, filters it for the year 2023 and the defined region of interest (North Morocco). A function is defined to mask out low confidence fire detections. Finally the fire collection is mosaicked and the Fire Radiative Power (FRP) band is selected.

5
Calculate NDVI and EVI
10 min

Add this block after the previous code. It continues the analysis with additional processing and visualization.

Calculate NDVI and EVI
// 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();
🔑
Beginner note: This code calculates the Normalized Difference Vegetation Index (NDVI) and Enhanced Vegetation Index (EVI) using MODIS surface reflectance data. Functions are defined for each index, and the MODIS data is filtered, scaled, renamed, and then used to calculate the indices.

6
Export Results to Google Drive
5 min

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 to Google Drive
//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
});
🔑
Beginner note -- Export.image.toDrive(): This function does not export immediately. It creates a task in the GEE Tasks tab that you must manually start by clicking Run. The file will appear in your Google Drive folder (GEE_Courses) as a GeoTIFF that you can open in QGIS or ArcGIS.

7
Exercises Using DeepSeek Prompts
Homework

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.

Explore MODIS Fire Data

  1. Import the MODIS fire data collection.
  2. Filter the data for a specific date range and region.
  3. Visualize the fire locations on the map.

Calculate and Visualize NDVI

  1. Import MODIS surface reflectance data.
  2. Calculate the NDVI using the appropriate bands.
  3. Visualize the NDVI layer on the map.

Analyze Land Surface Temperature

  1. Import MODIS land surface temperature data.
  2. Filter the data for your region of interest.
  3. Visualize the LST layer and explore its spatial patterns.

Combine Data Layers

  1. Calculate a weighted sum of FRP, NDVI, EVI, LST and elevation.
  2. Classify the resulting risk map into low, medium, and high risk categories.
  3. Visualize the final wildfire risk map.

8
Prompt Engineering Tips
Reference

To get the best results from DeepSeek for GEE tasks, always include these elements in your prompts:

ElementExample
Exact dataset IDMODIS/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"
🧠
Best practice: Start with the main prompt, run the code, then send follow-up prompts to add features one at a time. This gives you cleaner, more reliable code than asking for everything at once.
Course 10 - Wildfire Risk Mapping with MODIS and DeepSeek | GeoAI for Climate Change | Dr. Ayoub Lahlouh | UM6P/CUS | 2025/2026