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 |
|---|---|---|
| NDSI | Normalized Difference Snow Index | An index used to detect and map snow cover using the reflectance of visible and shortwave infrared light. |
| 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. |
| Snow Cover | Snow Cover | The area of land covered by snow. |
| Albedo | Albedo | The measure of the reflectivity of a surface. |
| Time Series | Time Series | A sequence of data points, typically consisting of successive measurements made over a time interval. |
| GEE | Google Earth Engine | A cloud-based platform for planetary-scale geospatial analysis. |
| Band | Spectral Band | A specific range of wavelengths in the electromagnetic spectrum. |
| Image Collection | Image Collection | A stack of images in Google Earth Engine, usually representing a time series. |
| Pixel | Pixel | The smallest addressable element in an image. |
| Cloud Masking | Cloud Masking | The process of removing or reducing the effect of clouds in satellite imagery. |
| Threshold | Threshold | A value that separates two categories. |
| Remote Sensing | Remote Sensing | Acquiring information about an object or area from a distance, typically from aircraft or satellites. |
| Rif Mountains | Rif Mountains | A mountain range in northern Morocco. |
| Middle Atlas | Middle Atlas | A mountain range in Morocco, part of the Atlas Mountains. |
Snow cover is a crucial indicator of climate change and plays a significant role in water resources. This course introduces you to analyzing snow cover dynamics using MODIS data in Google Earth Engine (GEE). We will explore how to process, visualize, and analyze snow cover extent in North Morocco, and leverage AI tools like DeepSeek to generate GEE code.
MODIS/061/MOD10A1You need two browser tabs open side by side throughout this course.
Course8_Snow Cover Dynamics 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 (North Morocco).
var geometry = ee.Geometry.Rectangle([-6, 32, -2, 35]);
// Load the MODIS MOD10A1 snow cover dataset.
var snowCover = ee.ImageCollection('MODIS/061/MOD10A1')
.filterDate('2020-01-01', '2023-12-31')
.filterBounds(geometry);
// Filter for December, January, and February.
var winterSnow = snowCover.filter(ee.Filter.calendarRange(12, 2, 'month'));
print('MODIS Snow Cover Collection:', winterSnow);
Add this block after the previous code. It continues the analysis with additional processing and visualization.
// Calculate the mean NDSI snow cover for each year.
var annualSnow = ee.List.sequence(2020, 2023).map(function(year) {
var startDate = ee.Date.fromYMD(year, 12, 1);
var endDate = ee.Date.fromYMD(ee.Number(year).add(1), 2, 28);
var annualImage = winterSnow.filterDate(startDate, endDate)
.mean()
.clip(geometry);
return annualImage.set('year', year);
});
annualSnow = ee.ImageCollection.fromImages(annualSnow);
// Define visualization parameters.
var snowVisParams = {
min: 0.0,
max: 100.0,
palette: ['00008B', '0000FF', 'ADD8E6', 'FFFFFF']
};
// Display the annual mean NDSI snow cover as a map.
annualSnow.sort('year').iterate(function(image) {
var year = image.get('year');
Map.addLayer(image, snowVisParams, 'Mean Snow Cover ' + year);
});
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 mean snow cover image to Google Drive.
Export.image.toDrive({
image: annualSnow.first(),
description: 'Mean_Snow_Cover_2020',
folder: 'GEE_Exports',
scale: 500,
region: geometry,
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/MOD10A1 |
| 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" |