Creating vector contours from elevation data
Contours provides an effective visualization of terrain data by tracing a line along the same elevation to form a loop at set intervals in the dataset. Similar to the hillshade capability in QGIS, the Contour tool is provided by GDAL both as a menu option under the Raster menu in the Extraction category as well as a Processing Toolbox algorithm.
Getting ready
This recipe uses the DEM from https://geospatialpython.googlecode.com/files/dem.zip, which is used in the other recipes as well.
Unzip the file named dem.asc
and place it in your /qgis_data/rasters
directory.
How to do it...
In this recipe, we will load and validate the DEM layer, add it to the map, and then produce and load the contour vector as a layer. To do this, we need to perform the following steps:
Start QGIS.
From the Plugins menu, select Python Console.
Import the
processing
module.import processing
Load and validate the DEM:
rasterLyr = QgsRasterLayer("/qgis_data/rasters/dem.asc", "DEM...