Practical Course 12

Solar Potential Mapping

Estimate solar energy potential in North Morocco using PVGIS data and DeepSeek for site suitability analysis.
North Morocco ~2 hours Master - Climate Change and GeoAI
Dataset: ECMWF/ERA5_LAND/HOURLY ERA5-Land Hourly Reanalysis

📖 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
PVGISPhotovoltaic Geographical Information SystemA web-based tool for estimating solar radiation and photovoltaic performance.
Solar IrradianceSolar IrradianceThe amount of solar power incident on a surface, measured in watts per square meter (W/m²).
Photovoltaic (PV)PhotovoltaicA technology that converts sunlight directly into electricity.
Site Suitability AnalysisSite Suitability AnalysisThe process of evaluating different locations to determine the most appropriate site for a specific purpose.
Digital Elevation Model (DEM)Digital Elevation ModelA 3D representation of the Earth's surface elevation.
AspectAspectThe compass direction that a slope faces.
SlopeSlopeThe steepness or gradient of a surface.
Remote SensingRemote SensingAcquiring information about an object or area from a distance, typically using sensors on satellites or aircraft.
GEEGoogle Earth EngineA cloud-based platform for geospatial data analysis.
NetCDFNetwork Common Data FormA file format for storing scientific data.
ERA5-LandERA5-LandA reanalysis dataset providing a consistent view of land variables over time.
DeepSeekDeepSeekAn AI model used for generating code and assisting with data analysis tasks.

Contents

  1. Introduction to Solar Energy Potential
  2. Introduction to PVGIS
  3. Accessing and Preparing ERA5-Land Data in GEE
  4. Calculating Solar Irradiance
  5. Generating a DEM from SRTM
  6. Site Suitability Criteria
  7. Using DeepSeek for Suitability Mapping
  8. Refining the Analysis with GEE
  9. Visualizing and Exporting Results
  10. Conclusion
1
Introduction
10 min

This course explores how to map solar energy potential in North Morocco using PVGIS principles and the DeepSeek AI model. You will learn to access and process climate data in Google Earth Engine (GEE) and combine it with terrain information to identify optimal locations for solar panel installations. This course is designed for beginners with some familiarity with GEE and remote sensing.

GEE Asset ID
ECMWF/ERA5_LAND/HOURLY
Dataset Name
ERA5-Land Hourly Reanalysis
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 Solar Potential Mapping, 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 Course12_Solar Potential Mapping
💡
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
I want to create a Google Earth Engine script to map solar energy potential in the Rif Mountains and Middle Atlas regions of Morocco. Use ERA5-Land hourly data (ECMWF/ERA5_LAND/HOURLY) for 2022 to calculate annual solar irradiance. Incorporate SRTM DEM data (USGS/SRTMGL1_003) to analyze slope and aspect. Identify areas suitable for solar panel installations based on the following criteria: annual solar irradiance greater than 1800 kWh/m², slope less than 20 degrees, and aspect facing south (135-225 degrees). Exclude areas with forest cover (COPERNICUS/Landcover/100m/Proba-V-C3/Global). Output a suitability map highlighting optimal locations for solar farms. Provide the complete Google Earth Engine JavaScript code.
✨
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
Importing and Filtering 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.

Importing and Filtering Data
// Define the region of interest (Rif Mountains and Middle Atlas, Morocco)
var roi = ee.Geometry.Rectangle([-6, 32, -2, 35]);

// Import ERA5-Land hourly data for 2022
var era5 = ee.ImageCollection('ECMWF/ERA5_LAND/HOURLY')
  .filterDate('2022-01-01', '2022-12-31')
  .filterBounds(roi);

// Print the number of images in the collection
print('Number of ERA5 images:', era5.size());

// Import SRTM DEM data
var dem = ee.Image('USGS/SRTMGL1_003').clip(roi);

// Import land cover data
var landcover = ee.Image('COPERNICUS/Landcover/100m/Proba-V-C3/Global').select('discrete_classification').clip(roi);
🔑
Beginner note: This code block imports the necessary datasets: ERA5-Land for climate data, SRTM for elevation, and COPERNICUS for land cover. It filters the ERA5-Land data for the year 2022 and clips all datasets to the defined region of interest (ROI) in North Morocco. The print statement is useful to check that data is being imported correctly. The landcover image is also clipped to the ROI and the 'discrete_classification' band is selected.

5
Calculating Solar Irradiance and Terrain Attributes
10 min

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

Calculating Solar Irradiance and Terrain Attributes
// Calculate daily solar irradiance (example, needs adjustment based on ERA5 bands)
var dailyIrradiance = era5.map(function(image) {
  // Assuming 'surface_solar_radiation_downwards' is the relevant band and converting from J/m² to kWh/m²
  var irradiance = image.select('surface_solar_radiation_downwards').multiply(2.777e-7); // J/m² to kWh/m²
  return irradiance.set('system:time_start', image.get('system:time_start'));
});

// Calculate annual solar irradiance
var annualIrradiance = dailyIrradiance.sum();

// Calculate slope and aspect from DEM
var slope = ee.Terrain.slope(dem);
var aspect = ee.Terrain.aspect(dem);

// Forest cover mask (assuming forest is classified as 5 or 6 in landcover)
var forestMask = landcover.eq(5).or(landcover.eq(6));
🔑
Beginner note: This block calculates the daily and annual solar irradiance from the ERA5-Land data. It also calculates the slope and aspect from the SRTM DEM. A forest mask is created based on the land cover data, assuming forest is classified as 5 or 6. The 'surface_solar_radiation_downwards' band from ERA5-Land is selected and converted to kWh/m². The slope and aspect are calculated using the `ee.Terrain` functions.

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 suitability map to Google Drive
Export.image.toDrive({
  image: annualIrradiance,
  description: 'Solar_Irradiance_North_Morocco',
  folder: 'GEE_Exports',
  scale: 30, // Adjust scale as needed
  region: roi,
  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 ERA5-Land Bands

  1. Print the properties of an ERA5-Land image to identify available bands.
  2. Find the correct band name for surface solar radiation downwards.

Adjust Irradiance Calculation

  1. Modify the code to correctly convert ERA5-Land solar radiation units to kWh/m².
  2. Verify the unit conversion factor.

Refine Forest Mask

  1. Inspect the land cover classification scheme and adjust the forest mask accordingly.
  2. Consider other land cover types to exclude.

Explore Different Regions

  1. Change the region of interest to another area in Morocco or elsewhere.
  2. Analyze the impact on solar potential.

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 IDECMWF/ERA5_LAND/HOURLY
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 12 - Solar Potential Mapping | GeoAI for Climate Change | Dr. Ayoub Lahlouh | UM6P/CUS | 2025/2026