I often get asked to create contours from DEM for engineers and architects for site planning purposes. I primarily use ArcGIS Pro at work to generate contours with ESRI provided terrain data or Lidar derived DEM. But for this tutorial I will show you how to generate contours from a publicly available DEM using QGIS.
For this tutorial, I am using a 30-meter (1-arc-second) SRTM DEM. There are various ways you can download this data. Below are some options with some tips on downloading and using the SRTM data. This tutorial provides detailed instructions for option 4 which is using the SRTM downloader plugin directly in QGIS (version 3.22).
Notes on SRTM data
If you are not familiar with SRTM data, here are some quick notes on to keep in mind.
There are 3 versions of SRTM data. Version 1 is the semi raw data (which you do not want), version 2.1 is non-void filled, and version 3 (SRTM Plus) is void-filled. Version 3 is the version used here
SRTM comes in either 1-arc second (30 meters) or 3-arc seconds (90 meters) and are divided into 1°×1° data tiles.
Data downloads are distributed as a zipped file in *.hgt format. The filename of the *.hgt file is labeled with the coordinate of the southwest (bottom left corner) cell. For example, the file N45W122.hgt contains data from 45°N to 46°N and from 122°E to 123°E inclusive.
*IMPORTANT: the name of the *.hgt file actually contains the source of the file’s georeferencing or coordinate system – DO NOT rename the file, otherwise it will not display properly
QGIS with GDAL support can natively read the hgt files (as long as the file hasn’t been renamed)
For more information on SRTM , check out the resources linked below:
SRTM Download Options
NOTES: Some sources require an account to download data. These accounts are free but you need to register first before you can download data.
Options 1 and 4 requires a NASA Earth Data account to download data. Register for a free account at https://urs.earthdata.nasa.gov/
Option 2 requires an email address for monitoring download progress
Option 3 requires a USGS Earth Explorer account. Register for a free account at https://ers.cr.usgs.gov/register
Option 1: SRTM Tile Downloader
This is a nice and simple web app that allows you to quickly download SRTM tiles (1°×1° tiles). I wished it had an option to change basemap for viewing purposes.
Tip on extracting the zipped file: When extracting the downloaded file (e.g. N45W122.SRTMGL1.hgt.zip) make sure the extracted folder does not contain the .hgt extension, otherwise QGIS will see the folder as N45W122.SRTMGL1.hgt and think it is a data format (which will not display) instead of N45W122.SRTMGL1.
Option 2: OpenTopography Download Site
The OpenTopography site does not require an account to download but it does require an email address when submitting download request, so you can describe and keep track of your data download. You can specify a custom AOI extent instead of downloading by tile. This site also has the option to download data as a Geotif, Arc ASCI Grid, or IMG file. However, the data is provided as a tar.gz file, which you will have to unzip first - see the tip below.
Tip on extracting TAR.GZ on Windows 10 OS:
Run Command Prompt as an administrator
cd into directory containing the zipped file (eg. cd C:\temp)
use the tar -xvzf command on the zipped file (e.g. type in tar -xvzf rasters_SRTMGL1.tar.gz)
Option 3: USGS Earth Explorer
This option requires you to have an Earth Explorer account to download data. It’s not quite as easy to use as some of the other options, but it allows you to download other types of datasets as well as being able to upload a shapefile or KML for your AOI. It also offers download options as Geotif, BIL, DTED formats.
Option 4: SRTM Downloader QGIS Plugin
With this option, you can download SRTM data directly in QGIS. You will need to install the SRTM downloader plugin and also have an Earth Data account. This is the option I will show you here.
Install SRTM-Downloader Plugin
To install the SRTM downloader plugin:
In QGIS (I am using version 3.22), go to Plugins menu >> Manage and Install Plugins
In the Plugins window:
select All >> search for SRTM-Downloader and select it >> Click Install Plugin.
you should get a “plugin installed successfully” message. Close the window
Download SRTM Tile in QGIS
After installing the SRTM-Downloader plugin, you’ll want to add in a basemap and zoom in to your area of interest (AOI). Here, I am using an OpenTopoMap as the basemap. My AOI is Mount Hood, OR.
Open the SRTM downloader:
Go to Plugins menu >> SRTM-Downloader >> SRTM downloader
In the SRTM downloader window: enter your parameters for your AOI and select a folder to download the tile to
After you click the Download button, another window should pop up asking you for your Earth Data account login
When it’s done downloading, the DEM should be loaded in QGIS (unless you uncheck that option in the download window). Here is my DEM tile for Mount Hood area.
Create Contours from DEM
Now that you have a DEM, you can create contours from it.
Go to Raster menu >> Extraction >> Contours
In the Contour window: enter your parameters: eg. 50 meter interval, save to file as a shapefile, geopackage, dxf, etc.
Here is my resulting contours at 50 meter interval.
Here’s a close up view showing the contours (magenta lines) on top of OpenTopoMap - the contours generated from the SRTM DEM at 50 meters interval matches up well with the topo lines shown on the OpenTopoMap (topo lines are also derived from SRTM data).
That’s it for this tutorial. Thanks for reading. Until next time…
Bonus Follow Up - Tips on DEM and Contour Visualization