Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
podcast
Filter by Categories
ArcGIS Pro
GDAL
GeoJson
Map
Map Tools
Maps
postgis
Python
QGIS
Uncategorized

Mastering Contour Lines and Labels in QGIS

Mastering Contour Lines and Labels in QGIS: A Step-by-Step Guide

In this guide, we’ll walk through the essential steps to extract contour lines from a raster file in QGIS, update their symbology, and add labels to make your map visually appealing.

Adding Your Raster Layer

To begin, you need to add your raster layer to the QGIS project. 

Need some raster data to work with? click here

Adding raster layer in QGIS

Extracting Contour Lines

Next, we’ll extract the contour lines from the raster file. Go to the menu and select Raster > Extraction > Contour. If you have multiple files, you can select the appropriate one from the dropdown menu.

Extracting contour lines from raster

For this example, keep the default settings for the band number and the interval between contour lines, which is set to ten. You can adjust this interval if needed. Ensure to save the contour shapefile to your project folder.

Saving contour shapefile

Styling the Contour Lines

After extracting the contours, you’ll want to enhance their appearance. Select the shapefile and access the properties either by double-clicking or right-clicking and selecting Properties.

Accessing shapefile properties

Under the Symbology tab, change the color to black and apply the changes.

Changing symbology color

Adding Labels to Contour Lines

Now, let’s add labels to the contour lines. Right-click on your contour shapefile and select Open Attribute Table to view the elevation field that was created.

Opening attribute table for contour

Go to the Labels tab in the properties window, switch from No Labels to Single Labels, and select the elevation field as the label value. Adjust the text size as needed.

Adding labels to contour lines

By default, labels will appear above the lines. To change this, navigate to the Placement section and set it to display labels on the line instead. Apply the changes.

Adjusting label placement

Creating Index Contours

If you want to highlight specific intervals, such as every hundred meters, you’ll need to create a new field called Index Contour. Open the attribute table and click on the field calculator icon.

Creating index contour field

Set the output field name to Index Contour and use an expression to identify the intervals. This will allow you to label contours at your desired intervals.

Setting expression for index contour

Enhancing the Map with Raster Layers

To improve the visual quality of the raster layers, you can duplicate the layer and change the symbology to Hillshade. Adjust the Z factor to refine the appearance.

Changing raster layer to hillshade

For the top layer, switch to Single Band Pseudo Color and select an appealing color ramp. You can find numerous options available for selection.

Selecting color ramp for raster

Final Adjustments

Finally, remember to adjust the transparency settings so that the underlying hillshade is visible. This will give your map a more dynamic look.

Adjusting transparency settings

With these steps, you have successfully extracted contour lines, styled them, added labels, and enhanced your raster layers in QGIS. 

FAQ

What are contour lines?

Contour lines are lines drawn on a map connecting points of equal elevation, providing a visual representation of terrain relief.

How do I find DEM raster files?

You can find Digital Elevation Model files from various online sources, including OpenTopography.org.

About the Author
I'm Daniel O'Donohue, the voice and creator behind The MapScaping Podcast ( A podcast for the geospatial community ). With a professional background as a geospatial specialist, I've spent years harnessing the power of spatial to unravel the complexities of our world, one layer at a time.