Tutorial: Working with Terrain Data in QGIS

Tutorial moved to  http://www.qgistutorials.com/en/docs/working_with_terrain.html

Terrain or elevation data is useful for many GIS Analysis and it is often used in maps. QGIS has good terrain processing capabilities built-in. In this tutorial, we will work through the steps to generate various products from elevation data such as contours, hillshade etc. The Raster menu comes from the GdalTools plugin. If you do not see the options under Raster menu, please follow this tutorial to find and enable the plugin.

The task is to create contours and hillshade map for area around Mt. Everest. We will be working with GMTED2010 dataset from USGS. This data can be downloaded from the USGS Earthexplorer site. GMTED (Global Multi-resolution Terrain Elevation Data) is a global terrain dataset that is the newer version of GTOPO30 dataset. For this tutorial, I downloaded a 7.5 arc” subset covering the Himalayas.

  • Once you have downloaded the data, extract it to a directory. Elevation data is distributed in various raster formats such as ASC, BIL, GeoTiff etc. QGIS supports a wide variety of raster formats via the GDAL library. The GMTED data comes as GeoTiff files. There are many different GeoTiff generated from different algorithms. For this tutorial, we will use the file named 10n060e_20101117_gmted_mea075.tif. Load the raster file in QGIS canvas by going to Layer → Add Raster Layer.
  • Find the area of interest. From Wikipedia, we find the coordinates for the area of interest. Mt. Everest is located at the coordinates 27.9881° N, 86.9253° E. Note that QGIS uses the coordinates in (X,Y) format , so you must use the coordinates as (Longitude, Latitude). Paste “86.9253,27.9881” these at the bottom of QGIS window where it says Coordinate and press Enter. The viewport will be centered at this coordinate. To zoom in, Enter 1:100000 in the Scale field and Press Enter.
  • We will now crop the raster to this area of interest. Select the Clipper tool from Raster → Extraction → Clipper.
  • In the Clipper tool window, name your Output file as ‘himalayas.tif’. Then set the Clipping mode to Extent. Switch back to QGIS canvas, hold down the left mouse button and select a rectangle covering your viewport. The extent coordinates should be automatically populated. Check the box that says ‘Load into canvas when finished’. Click OK.
  • Once the processing in complete, you will get a new layer in your Table of Contents. Right click on the original raster and click ‘remove’.
  • Now we are ready to generate contours. Select the contour tool from Raster → Extraction → Contour
  • In the Contour tool, name your output file as contours.shp. We will generate contour lines for 100m intervals, so put 100 as the Interval between contour lines. Check the boxes next to Attribute name and Load into canvas when finished. Click OK.
  • Once the processing is complete, you will see contour lines loaded into the canvas. Each line in this layer represents a particular elevation. All points along a countour line in the underlying raster would be at the same elevation. The closer the lines, the steeper the slope.
  • Let’s inspect the contours a bit more. Right click on the contours layer and click Open Attribute Table. You will see that each line feature as an attribute named ELEV. This is the height in metres that each line represents. Click on the column header a couple of times to sort the values in descending order. Here you will find the line representing the highest elevation in our data, i.e. Mt. Everest.
  • You can visualize these contours and verify your analysis by exporting the contours layer as KML and viewing it in Google Earth. Right click on the contours layer, select ‘Save as..’. Select Keyhole Markup Language (KML) as output format and name your output file himalayas.kml. Browse to the output file and double-click on it to open Google Earth.
  • Now let us create a hillshade map from the raster. Select Raster → Analysis → DEM (Terrain Models).
  • In the hillshade dialog box, name your output file as hillshade.tif. Select ‘Hillshade’ as the Mode. Check the box next to Load into canvas when finished. Click OK.
There are many other terrain related options available under the Raster menu. We will explore those in a later tutorial.

Pro Tip: If you are working with large amount of raster or terrain data, it would be worthwhile to learn about the GDAL utilities. If you noticed, the clipper, contour and hillshade tools all used GDAL commands in the background to create the rasters. The gdal commands are displayed in the tool window as you select various options. Learning the command-line options for these utilities will help you automate or batch process large amount of data. Learn more at GDAL Utilities page.