Practical Course 5

Urban Heat Island Mapping with Landsat and DeepSeek

Learn to map urban heat islands using Landsat satellite imagery, Google Earth Engine, and DeepSeek AI to understand temperature variations in North Moroccan cities.
North Morocco ~2 hours Master - Climate Change and GeoAI
Dataset: LANDSAT/LC08/C01/T1_SR Landsat 8 Surface Reflectance

📖 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
UHIUrban Heat IslandA metropolitan area which is significantly warmer than its surrounding rural areas.
LSTLand Surface TemperatureThe radiative skin temperature of the land surface, measured in Kelvin or Celsius.
NDVINormalized Difference Vegetation IndexA simple graphical indicator that measures the amount of live green vegetation.
EmissivitySurface EmissivityThe measure of an object's ability to emit infrared energy.
LandsatLandsat ProgramA long-running Earth observation satellite program.
GEEGoogle Earth EngineA cloud-based platform for planetary-scale geospatial analysis.
TIRSThermal Infrared SensorThe sensor on Landsat satellites that measures thermal radiation.
OLIOperational Land ImagerThe sensor on Landsat satellites that measures visible and near-infrared radiation.
Surface ReflectanceSurface ReflectanceThe fraction of incoming solar radiation reflected from the Earth's surface after atmospheric correction.
Atmospheric CorrectionAtmospheric CorrectionThe process of removing atmospheric effects from satellite imagery.
PixelPicture ElementThe smallest addressable element in an image.
BandSpectral BandA specific range of wavelengths in the electromagnetic spectrum that a sensor is sensitive to.
ThresholdThresholdA value used to separate data into different categories.
AlgorithmAlgorithmA process or set of rules to be followed in calculations or other problem-solving operations.

Contents

  1. Introduction to Urban Heat Islands
  2. Landsat 8 Data Acquisition
  3. Calculating NDVI
  4. Calculating Land Surface Temperature (LST)
  5. UHI Mapping in Google Earth Engine
  6. Using DeepSeek for Analysis
  7. Visualizing and Interpreting Results
  8. Accuracy Assessment
  9. Case Studies in North Morocco
  10. Conclusion and Further Exploration
1
Introduction
10 min

Urban Heat Islands (UHIs) are a growing concern, especially in rapidly urbanizing areas. This course will guide you through mapping UHIs in North Morocco using Landsat 8 data and the power of Google Earth Engine and DeepSeek AI, providing a hands-on experience in remote sensing and GeoAI.

GEE Asset ID
LANDSAT/LC08/C01/T1_SR
Dataset Name
Landsat 8 Surface Reflectance
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 Urban Heat Island Mapping with Landsat 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 Course5_Urban Heat Island Mapping with Landsat 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
Analyze Landsat 8 data from July 1, 2023, to August 31, 2023, over Fez, Morocco (34.0372° N, 5.0069° W). Calculate NDVI using bands 'B5' (Near Infrared) and 'B4' (Red). Calculate LST using band 'B10' (Thermal Infrared). Identify and delineate urban heat islands based on LST values above 35 degrees Celsius. Provide a map showing NDVI, LST, and the identified UHI areas. The LANDSAT/LC08/C01/T1_SR dataset should be used.
✨
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
Landsat 8 Data Acquisition and NDVI Calculation
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.

Landsat 8 Data Acquisition and NDVI Calculation
// Define the region of interest (Fez, Morocco)
var fez = ee.Geometry.Point([ -5.0069, 34.0372]);

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

// Load Landsat 8 SR data
var landsat8 = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
  .filterBounds(fez)
  .filterDate(startDate, endDate)
  .filter(ee.Filter.lt('CLOUD_COVER', 20));

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

// Apply NDVI calculation to the Landsat 8 collection
var ndviCollection = landsat8.map(calculateNDVI);

// Composite the NDVI collection (e.g., median)
var ndvi = ndviCollection.median();

//Display NDVI
Map.addLayer(ndvi, {min: -1, max: 1, palette: ['blue', 'white', 'green']}, 'NDVI');
🔑
Beginner note: This code block first defines the area of interest, the date range, and loads the Landsat 8 Surface Reflectance dataset. It then defines a function to calculate the Normalized Difference Vegetation Index (NDVI) using the Near Infrared (B5) and Red (B4) bands. The NDVI function is applied to the Landsat 8 image collection, and the median NDVI is calculated and displayed.

5
Land Surface Temperature (LST) Calculation
10 min

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

Land Surface Temperature (LST) Calculation
// Function to calculate LST (simplified)
var calculateLST = function(image) {
  var thermalBand = image.select('B10');
  var kelvin = thermalBand.multiply(0.1).add(273.15); // Convert to Kelvin
  return kelvin.rename('LST');
};

// Apply LST calculation to the Landsat 8 collection
var lstCollection = landsat8.map(calculateLST);

// Composite the LST collection (e.g., median)
var lst = lstCollection.median();

//Display LST
Map.addLayer(lst, {min: 290, max: 320, palette: ['blue', 'yellow', 'red']}, 'LST');

// Define a threshold for UHI (e.g., LST > 308 K)
var uhiThreshold = 308;

// Create a UHI mask
var uhiMask = lst.gt(uhiThreshold);

// Display the UHI mask
Map.addLayer(uhiMask.updateMask(uhiMask), {palette: 'red'}, 'UHI Mask');
🔑
Beginner note: This code block calculates Land Surface Temperature (LST) from the Landsat 8 thermal band (B10). It converts the band values to Kelvin. Then, it defines a temperature threshold to identify Urban Heat Island areas. A mask is created based on this threshold and displayed on the map.

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 LST image to Google Drive
Export.image.toDrive({
  image: lst,
  description: 'LST_Fez',
  folder: 'GEE_Exports',
  scale: 30,
  region: fez,
  maxPixels: 1e9
});
🔑
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 Different Regions

  1. Change the region of interest to another city in North Morocco (e.g., Tangier, Casablanca).
  2. Run the script and observe the changes in NDVI and LST.

Adjust the Date Range

  1. Modify the start and end dates to cover different seasons.
  2. Analyze how the UHI effect varies seasonally.

Experiment with UHI Thresholds

  1. Change the `uhiThreshold` value and observe the impact on the UHI mask.
  2. Determine the optimal threshold for identifying UHIs in your study area.

Incorporate Land Cover Data

  1. Add a layer showing land cover types from a dataset like ESA WorldCover.
  2. Analyze the relationship between land cover and LST.

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 IDLANDSAT/LC08/C01/T1_SR
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 5 - Urban Heat Island Mapping with Landsat and DeepSeek | GeoAI for Climate Change | Dr. Ayoub Lahlouh | UM6P/CUS | 2025/2026