A few weeks ago I
wrote a post on “Generating DEMs from Contours” which was quite a
straight forward 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.
Lets begin:
Assumption: You
have the DEM on your local machine.
Steps:
Launch QGIS 2.X
and Load our Raster Layer (DEM) i.e. Ken_dem (sample data for this
tutorial)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGA5QQR2jiJ5tQy83rr-RidC15mnGF6kqKkPkOGs0STEHkOAg2OFqp7Rxc3R8YrjfcBe77SD2DnkOh42tsGUF38efcQf6GI2KUP1CdUlEKlCT8RG6fpRE1oFXvJ3J7oESU-mvDqdkqdDMg/s1600/first.PNG) |
DEM loaded in QGIS |
Go to Raster >
Extraction > Clipper (This will help us in clipping the area of
interest out of the entire Ken_dem dataset)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0Ko08cBFd97-_u4B-ldmBSyW28CGS3CCLnNJBjrPXuhAMZtxofUlGbup8WELovxYW1UsUF4oJ3UMtnSt34E-YChdCEYJCtLu8P4gABVtGsxOIAEE1j-NPY51jdqKhvipu2pwdUb3KevLC/s1600/second.png) |
Launching clipper window |
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.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEip-I6m8IphWUqgNaitJjOWv0qXGG-W6BRA4K3is9FIkMlu_QBj-O6hFfry1ZPqjyjPWhIb8IsseesxzeIQYTebSxiAo9l7gVoF7WqkWn9IaNTKMeSZtV7lS0MP9W6PaaljRrvaI2ExakTu/s1600/third.PNG) |
Clipper window |
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 different
color as shown)
Get back to the
Clipper window and check the x,y values.The values are autofilled
after selection on canvas.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhfj6GXbIk5EhLRu8eqZvLDIptE2vnGMURtmgyrJ5elOLw2JuAqLZk_IR7duZ7j30RtfNfllg0ewzg80yH9FhvMoCj2_ZHpHl3pkNz-M3vx82d7xwLXibBsHZEkt6QD-ynCecFpBLkVnJA/s1600/fourth.PNG) |
Selecting area on 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
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIT7P9yGlWHRNx86JbJtkSgCoaXb9-DuNfAt7xECTV-Jxa_qmFZl8BMHVqiPV_F9BnjVNbJrH6g_Da3KukuaNAqAEUJ2dKHbZEwAtbWyGq4rD1Pv0TGWcA5dbTIa2J_xTZTKADYDi6aGSt/s1600/fifth.png) |
Opening Contour window |
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 interval 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.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhulFpguLEXyLtnNFWLIaNt_leFbXyLGX1FIA-P_-GmJ55NFI169PCxg6pJBmjdNNcytykHW2Gin9PJU0z_eiwjMLohqtcN2swQGWcOmiDsjAYH-Ka9JuFO-8KtRPJ2br3lPiRCtc1Kiq_y/s1600/sixth.PNG) |
Contour window |
After processing
is complete, load the towns layer to see our town of interest.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEia-44bQzSkouY8TrZiheaGdC3-JrFmL3Up4RjCRce1kDUc1CHHZEZguphDG2zv5UOZ45OjI8a3Z5UHbSyVgjYbDolNV4to8EmFWAae1xPS9P7r9bBhDebR3JvpWZ4Bl0F-RzFyf2fhP9yM/s1600/seventh.PNG) |
Location of my town |
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcTQ_370Br-AelLpsri3NthMnx38B2PkiSx7R8OPJTsOnwWxQ8MTSolA9HEj3QYLgTXXnBQyeza8VwG2OPa8HUDxzLrCzAzxuseLU3qc1jhrPjZprRJgtFqaoGEi4Ya6oQAhwV7F22TLTa/s1600/eigth.PNG) |
The Elevation column |
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.