How to Generate Contour Lines with QGIS – Step-by-Step Guide

 

Introduction

Creating contour lines has always been a recurring task in my projects, QGIS stands out as an excellence choice. As a free and open-source software, QGIS combines ease of use with robust capabilities, making it a go-to solution for geospatial analysis. In this post, I'll guide you through the process of generating contour lines using QGIS, sharing tips and ticks I've picked up along the way to streamline the workflow and ensure precision.

Step 1: Add a DEM TIFF

To begin generating contour lines in QGIS, the first step is to load your Digital Elevation Model (DEM) file, typically in TIFF format. Here's how:

1. Open QGIS: Launch the QGIS application on your system.

2. Add Raster Layer:

  • Navigate to the Layer menu at the top.
  • Select Add Layer > Add Raster Layer.
  • Alternatively, you can click the Add Raster Layer icon in the toolbar.
3. Locate Your DEM File: In the file browser, find your DEM file (eg., .tiff) and click Open.
4. View the DEM: Your DEM should now appear in the Layers panel and be displayed on the map canvas.

DEM file

Ensure the DEM is properly visualized. You can adjust its rendering style in the Layer Style Panel to highlight elevation variations effectively. With your DEM load, you are ready to move on to generating contour lines.
Layers Panel

Step 2: Generate Contour Lines

Now that your DEM is loaded, it's time to generate contour lines. Follow these steps:

1. Open the Contour Tool:

  • In the menu bar, go to Raster > Extraction > Contour.
  • This will open the Contour dialog box.

Go to Raster > Extraction > Contour.
2. Configure Contour Interval:
  • In the Interval between contour lines field, enter 100 (or your desired interval in the same units as your DEM).
  • This determines the vertical spacing between each contour line.

Set 100 Distance
3. Set Output File:
  • Click the ... button next to the Output file for contour lines field.
  • Choose the location where you want to save the contour file and give it a name (e.g., contour_100m.shp).
4. Run the Tool:
  • Once everything is configured, click Run to start the process.
  • The progress will be displayed in the process window.
5. Check the Results:
  • After the process completes, the contour lines will be automatically added to your QGIS map canvas as a new layer..
Contour Line is generated

You now have contour lines generated with a 100-unit interval, ready to analysis or visualization.

Step 3: Label Contour Lines with Elevation Values

To make your contour lines more informative, you can label them with their corresponding elevation values. Here's how to do it:
1. Open Layer Properties:
  • In the Layers panel, right-click on the contour layer you just created (e.g., contour_100m) and select Properties.
  • Alternatively, double-click the layer to open the Layer Properties window.
2. Enable Labeling:
  • In the Layer Properties window, go to the Labels tab.
  • Set Label with to the attribute that contains the elevation values (usually ELEV or similar, depending on how the contour tool named it).
3. Customize Label Style (Optional):
  • Adjust font size, style and placement for better visibility:
    • Font size: Set an appropriate size for your map scale.
    • Buffer: Enable a text buffer (e.g., white outline) for contrast against the map background.
4. Apply Changes:
  • Click Apply and then OK to save your changes.
5. View the Labels:
  • The elevation values should now appear on your contour lines in the map canvas.

This step adds clarity and makes your map more interpretable by clearly indicating elevation values at regular intervals.


Conclusion

Generating contour lines with QGIS is a straightforward process that highlights the power of this open-source tool for geospatial analysis. By following these steps - adding a DEM file, generating contour lines, and labeling contour lines with elevation values. 

QGIS makes it easy to produce detailed, informative contour maps without the need for expensive software, empowering users to efficiently tackle tasks like terrain analysis, planning, or visualization. With these skills, you're well-equipped to handle contour mapping projects with confidence.

Comments

Popular posts from this blog

How to configure truststore at springboot