Download DEM and Slope data (SRTM) using Google Earth Engine

Indigo Brownhall
3 min readOct 13, 2020

--

A little background:

Downloading, processing and storing satellite data can be a serious pain. I remember pulling my hair out trying to find RGB imagery of the transboundary area from Cambodia to Vietnam without any cloud-cover (Synthetic Aperture Radar wasn’t applicable for my task at hand). Eventually, a colleague pointed me towards Google Earth Engine — an absolute Godsend!

Google Earth Engine (GEE) is a cloud-computing platform for processing satellite imagery and other geospatial and observational data. It allows all the heavy-computer processing on remote servers and is incredibly quick. It is also completely free!

When learning how to use GEE, I fortunately had direct help from an expert, but I often found it difficult to find easy to understand introductions for quick and simple analysis.

This blog will show you how to download and clip DEM and Slope data for the Lake District.

Loading up GEE:

Although it is free, you will still need a google earth account. Sign up here (https://code.earthengine.google.com/), it can take up to a couple of days to accept you.

Once you are accepted, the Code Editor looks like this:

Uploading your personal shapefile:

For this, I assume you have a basic knowledge of GIS and how to download and view vector (.shp) data in a Mapping Software. If you don’t there is loads of great info here and here.

The Lake District data in this tutorial can be downloaded from Edina Digimap.

Upload your shapefile using the Asset tab:

Upload the shapefile. It is now stored within Google Earth Engine. However, to use it in your scripts, import it into the Code Editor with the button above. Rename this variable as ‘lake_dis’.

Now we need to import the data that we are interested in:

NASA SRTM Digital Elevation 30m. You are able to type this into the dataset search bar, click on the dropdown result and then copy the code snippet from the pop-up window.

From this both elevation and slope can be calculated!

So copy and paste this in:

var dataset = ee.Image(‘USGS/SRTMGL1_003’);

var elevation = dataset.select(‘elevation’).clip(lake_dis);

var slope = ee.Terrain.slope(elevation).clip(lake_dis);

If we break this down, what are we doing?

Firstly ‘var’ allows you set a variable. This is just data that can be called on later in the code.

ee.’ Refers to earth engine. It calls on a function package that is made by Google. This is similar to calling a package in Python.

Image’ You are locating where the image (data) is! This is referring to Google’s Data.

‘.clip()’ instead of importing the whole world’s dataset (which would take ages!) we simply clip it to our area of interest.

ee.Terrain.slope’ is a function to calculate slope from the elevation. I wont go into how this is calculated, but you can read more on it here.

Remember, once a step in your code is complete. It must end with a semi-colon.

So now we have our datasets in varibles. We can now add them to a map! {min:, max} represents the min and max values of your raster. The string at the end will be the Layer name.

Map.addLayer(slope, {min: 0, max: 60}, ‘slope’);

Map.addLayer(elevation,{min:0, max:5000}, ‘slope’);

If we want to download them to our local drive to use in qGIS or ArcMAP you can export them to your google drive. This simply, exports the dataset as a string.

Export.image.toDrive(slope, ‘slope’);

Export.image.toDrive(elevation, ‘elevation’);

Press run on your script to see the results on the Map. Once you are happy with this, click on the Tasks tab and your data will be exported to your Google Drive.

All done! Now you have both an elevation and slope clipped exactly to the Lake District!

--

--

Indigo Brownhall

#PhD in Space Sustainability at UCL. Previous Technical Associate at Informed Solutions. Blogging on PhD, UCL life aswell as all things Geospatial and Software