Creating vector contours from elevation data

Contours provide an effective visualization of terrain data by tracing isolines 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 and as a Processing Toolbox algorithm.

Getting ready

This recipe uses the DEM from https://github.com/GeospatialPython/Learn/raw/master/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 ...

Get QGIS Python Programming Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.