Generating Contours from DEM in QGIS

      A few weeks ago I wrote a post on Generating DEMs from Contours which was quite a straightforward process as explained. In this post, I will show how to “reverse engineer” the process and generate contours from DEMs.
This time round am also going to demonstrate how to clip our dataset to work with the area of interest instead of working on the whole dataset.
Let’s begin:
Assumption: You have the DEM on your local machine.
If not so, data can be downloaded from either USGS EarthExplorer or from GeoComm
Steps:
Launch QGIS 2.X and Load our Raster Layer (DEM) i.e. Ken_dem (sample data for this tutorial)
Load DEM in QGIS
Go to Raster > Extraction > Clipper (This will help us in clipping the area of interest out of the entire Ken_dem dataset)
Launch clipper tool
I loaded the “towns_layer” to know my area of interest and zoom to the SELECTED town (Nakuru). This is the area I will be using as my area of interest.
In the clipper window, select the Output file location. On the Clipping mode check the Extent mode.

While still on clipper window, switch to the main QGIS window –Click on one corner of the canvas and hold on the left mouse button to drag to cover the entire Map canvas(The selection will be highlighted in a different color as shown)

Get back to the Clipper window and check the x,y values. The values are auto-filled after selection on canvas.

Select an area in canvas
Check the “Load into canvas when finished” to add our results into QGIS.Click Ok to clip.
The results are loaded into QGIS.
Now we can proceed on to generate contours.
Go to Raster > Extraction > Contour
  On the contour window, select the input file as the clipped file –clipper. Also, select the output file location. I will be generating contours with 50M intervals so select 50.
Check on “Attribute name” to auto-generate the elevation column of the output file.
Check on “Load into canvas when finished” to display our results when finished. Click OK to generate the contours.
After processing is complete, load the town’s layer to see our town of interest.
We can then go ahead and introduce the “Color Ramp” in the contours layer to categorize the layer.
I decided to use the “MMQGIS” plugin available in QGIS to build the color ramp.
In Menu bar, go to MMQGIS plugin > Modify > Color Ramp
In the color map window choose the layer field to participate in the categorization e.g. ELEV
Select the Ramp Type – Quantiles
Select the number of categories to be used (5).
Select the color for different categories.
Select the Preset and click OK
The results are displayed and well illustrated

That’s it. We just did an awesome task.
As usual, I would like to hear your views on this. Leave a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *

Wanjohi Kibui

Passionate about harnessing the power of geospatial technology to create innovative solutions, I'm a GIS Consultant and Developer dedicated to building cutting-edge geospatial applications. With a keen eye for spatial analysis and a knack for problem-solving, I specialize in crafting solutions that seamlessly integrate technology and geography.

More Reading

Post navigation