Google Earth Engine Tutorial: Download Slope and Aspect Maps
Credit: Youtube Channel “Terra Spatial, Tutorial on downloading slope and aspect raster maps derived from SRTM DEM data.”
You can see all the tutorials from here: Techgeo Academy.
Google Earth Engine (GEE) is a powerful platform for geospatial analysis that allows users to access satellite imagery and planetary datasets at scale. One common task in terrain analysis is generating slope and aspect maps, which provide critical insights for applications like hydrology, urban planning, and ecological modeling. Below is a step-by-step guide to create and download slope and aspect maps using GEE.
Step 1: Access Google Earth Engine
To begin, ensure you have a Google account and access to the Google Earth Engine Code Editor. Once logged in, open a new script window.
Step 2: Load Elevation Data
GEE offers multiple elevation datasets. The most popular is the Shuttle Radar Topography Mission (SRTM). Use the following code to load the SRTM dataset:
var dem = ee.Image("USGS/SRTMGL1_003");Step 3: Calculate Slope and Aspect
Use the elevation band of the DEM to compute slope and aspect. Slope represents the steepness of the terrain, while aspect indicates the direction it faces. Add the following code:
var slope = dem.select('elevation').slope();
var aspect = dem.select('elevation').aspect();Step 4: Visualize the Results
Display the slope and aspect maps in the GEE Code Editor. Use the Map.addLayer function to visualize them:
Map.addLayer(slope, {min: 0, max: 90, palette: ['black', 'white']}, 'Slope');
Map.addLayer(aspect, {min: 0, max: 360, palette: ['blue', 'green', 'red']}, 'Aspect');Step 5: Export the Maps
To download the slope and aspect maps, use the Export.image.toDrive function. Define the region of interest, scale, and file format (e.g., GeoTIFF). Example code for exporting slope:
Export.image.toDrive({
image: slope,
description: 'slope_export',
folder: 'GEE_Exports',
fileNamePrefix: 'slope_map',
scale: 30,
region: geometry,
maxPixels: 1e10,
format: 'GeoTIFF'
});Repeat the process for the aspect map by replacing slope with aspect.
Step 6: Retrieve the Files
Once the export is complete, the files will be saved in your Google Drive under the specified folder. Use a GIS software like QGIS or ArcGIS to open and analyze the GeoTIFFs.
FAQ
- What elevation datasets can I use? GEE provides datasets like SRTM, ASTER GDEM, and ALOS PALSAR. Choose the one with the desired resolution and coverage.
- Can I customize the visualization? Yes. Modify the palette and min/max values in the Map.addLayer function to suit your needs.
- How do I define the region of interest? Use geometry variables (e.g., geometry = ee.Geometry.Rectangle([lon1, lat1, lon2, lat2])) or upload a KML file to define your area.
- Why is my export taking too long? Adjust the scale parameter or use a smaller region. Large areas might require higher maxPixels values, which can be set in the export options.
- Can I export to other formats besides GeoTIFF? Yes, but GeoTIFF is recommended for maintaining geospatial metadata. Supported formats include PNG, JPEG, and TIFF.





