Practical Course 18

Dust Storm Detection with MODIS and DeepSeek

Learn to detect dust storms in North Africa using satellite imagery and AI-powered code generation.
North Morocco ~2 hours Master - Climate Change and GeoAI
Dataset: MODIS/061/MOD09GA MODIS Terra Surface Reflectance Daily Global 1km

📖 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 and Aqua satellites, providing daily global observations.
Surface ReflectanceSurface ReflectanceThe fraction of incoming solar radiation reflected from the Earth's surface.
Dust StormDust StormA meteorological phenomenon where strong winds lift large quantities of dust and sand into the air.
AerosolsAerosolsTiny particles suspended in the atmosphere, affecting air quality and climate.
NDVINormalized Difference Vegetation IndexA simple graphical indicator used to analyze remote sensing measurements, often used to assess the presence of live green vegetation.
GEEGoogle Earth EngineA cloud-based platform for planetary-scale geospatial analysis.
BandSpectral BandA specific range of wavelengths in the electromagnetic spectrum that a sensor is designed to detect.
ThresholdThresholdA value used to separate different classes or features in an image.
PixelPixelThe smallest unit of an image, representing a single value or set of values.
ClassificationImage ClassificationThe process of assigning pixels in an image to specific categories or classes.
False Color CompositeFalse Color CompositeA color image created by assigning different bands of multispectral data to the red, green, and blue channels.
DeepSeekDeepSeek CoderAn AI model designed to generate code from natural language prompts.

Contents

  1. Introduction to Dust Storms
  2. MODIS Data Acquisition
  3. Data Preprocessing
  4. Visualizing Dust Storms
  5. Introduction to DeepSeek
  6. DeepSeek Prompt Engineering
  7. Generating Dust Storm Detection Code
  8. Code Refinement and Validation
  9. Exporting Results
  10. Conclusion and Further Exploration
1
Introduction
10 min

Dust storms are a recurring environmental hazard in North Africa, impacting air quality and visibility. This course will guide you through using MODIS satellite data and the power of DeepSeek to automatically detect and visualize these events in the Rif Mountains and Middle Atlas region of Morocco. You'll learn how to access, process, and analyze MODIS data within Google Earth Engine, and use DeepSeek to generate code for dust storm detection.

GEE Asset ID
MODIS/061/MOD09GA
Dataset Name
MODIS Terra Surface Reflectance Daily Global 1km
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 Dust Storm Detection 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 Course18_Dust Storm Detection 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
Write a Google Earth Engine JavaScript code to detect dust storms in North Morocco (Rif Mountains and Middle Atlas) using MODIS/061/MOD09GA surface reflectance data. Use data from 2023-07-01 to 2023-07-31. Use bands 'sur_refl_b01', 'sur_refl_b03', and 'sur_refl_b04' to create a false-color composite that highlights dust. Also calculate NDVI using bands 'sur_refl_b02' and 'sur_refl_b01' and use a threshold of NDVI < 0.1 to help identify dust. Display the false color composite and the dust storm classification result on 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
Data Acquisition and Preprocessing
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.

Data Acquisition and Preprocessing
// Define the region of interest (North Morocco).
var roi = ee.Geometry.Rectangle([-6, 32, -2, 35]);

// Define the date range.
var startDate = '2023-07-01';
var endDate = '2023-07-31';

// Load the MODIS surface reflectance dataset.
var modis = ee.ImageCollection('MODIS/061/MOD09GA')
    .filterDate(startDate, endDate)
    .filterBounds(roi);

// Function to calculate NDVI.
var calculateNDVI = function(image) {
  return image.normalizedDifference(['sur_refl_b02', 'sur_refl_b01']).rename('NDVI');
};

// Apply the NDVI calculation to the MODIS collection.
var modisWithNDVI = modis.map(calculateNDVI);
🔑
Beginner note: This code block first defines the region of interest (ROI) as a rectangle in North Morocco and sets the time frame for data acquisition. Then, it loads the MODIS surface reflectance dataset from Google Earth Engine, filtering it by date and location. A function is defined to calculate the Normalized Difference Vegetation Index (NDVI) using the near-infrared (band 2) and red (band 1) bands. Finally, this function is applied to the MODIS image collection to add the NDVI band to each image.

5
Dust Storm Detection and Visualization
10 min

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

Dust Storm Detection and Visualization
// Composite the MODIS collection to a single image (median).
var modisImage = modisWithNDVI.median().clip(roi);

// Define a threshold for NDVI to identify potential dust areas.
var ndviThreshold = 0.1;

// Create a mask for dust storms based on the NDVI threshold.
var dustMask = modisImage.select('NDVI').lt(ndviThreshold);

// Create a false-color composite for visualization.
var falseColor = modisImage.select(['sur_refl_b04', 'sur_refl_b03', 'sur_refl_b01']).multiply(0.0001);

// Display the false-color composite on the map.
Map.addLayer(falseColor, {min: 0, max: 0.3}, 'False Color Composite');

// Display the dust storm mask on the map.
Map.addLayer(dustMask.updateMask(dustMask), {palette: 'red'}, 'Dust Storms');
🔑
Beginner note: This block begins by creating a median composite image from the MODIS collection to reduce cloud cover. It then sets an NDVI threshold to identify dust storms (lower NDVI values often indicate less vegetation and potentially dust). A mask is created based on this threshold. A false-color composite is created using specific MODIS bands (5,4,3) to visually highlight dust. Finally, both the false-color composite and the dust storm mask are added to the map for visualization. The red color highlights areas identified as dust storms.

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 dust storm mask to Google Drive.
Export.image.toDrive({
  image: dustMask,
  description: 'Dust_Storm_Mask',
  folder: 'GEE_Exports',
  region: roi,
  scale: 1000,
  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.

Adjust the NDVI Threshold

  1. Modify the 'ndviThreshold' variable to 0.05 and observe the changes in the dust storm mask.
  2. Try a higher threshold like 0.15 and compare the results.

Explore Different Time Periods

  1. Change the 'startDate' and 'endDate' variables to analyze dust storm activity in a different month.
  2. Compare the dust storm detection results for different seasons.

Refine the ROI

  1. Modify the 'roi' variable to focus on a specific area within North Morocco.
  2. Analyze the dust storm patterns in that smaller region.

Visualize using different band combinations

  1. Modify the bands used to create the false-color composite.
  2. Research which band combinations best highlight dust storms and use them.

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/MOD09GA
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 18 - Dust Storm Detection with MODIS and DeepSeek | GeoAI for Climate Change | Dr. Ayoub Lahlouh | UM6P/CUS | 2025/2026