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 |
|---|---|---|
| PVGIS | Photovoltaic Geographical Information System | A web-based tool for estimating solar radiation and photovoltaic performance. |
| Solar Irradiance | Solar Irradiance | The amount of solar power incident on a surface, measured in watts per square meter (W/m²). |
| Photovoltaic (PV) | Photovoltaic | A technology that converts sunlight directly into electricity. |
| Site Suitability Analysis | Site Suitability Analysis | The process of evaluating different locations to determine the most appropriate site for a specific purpose. |
| Digital Elevation Model (DEM) | Digital Elevation Model | A 3D representation of the Earth's surface elevation. |
| Aspect | Aspect | The compass direction that a slope faces. |
| Slope | Slope | The steepness or gradient of a surface. |
| Remote Sensing | Remote Sensing | Acquiring information about an object or area from a distance, typically using sensors on satellites or aircraft. |
| GEE | Google Earth Engine | A cloud-based platform for geospatial data analysis. |
| NetCDF | Network Common Data Form | A file format for storing scientific data. |
| ERA5-Land | ERA5-Land | A reanalysis dataset providing a consistent view of land variables over time. |
| DeepSeek | DeepSeek | An AI model used for generating code and assisting with data analysis tasks. |
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.
ECMWF/ERA5_LAND/HOURLYYou need two browser tabs open side by side throughout this course.
Course12_Solar Potential Mapping
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 (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);
Add this block after the previous code. It continues the analysis with additional processing and visualization.
// 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));
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 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
});
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 | ECMWF/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" |