Creating Contour Lines in QGIS

Contour lines are lines that connect points of equal elevation on a map, allowing the terrain’s relief to be visualized. A DEM (Digital Elevation Model) is a raster representation of the terrain relief. In this tutorial, you will learn how to import and generate contour lines from a DEM in QGIS.

  1. Preparations Before Importing the DEM

Ensure the DEM is in flat or UTM coordinates. If it’s not in this format, consider re-projecting it before continuing: Raster > Projections > Warp (Reproject).

Raster files typically have a .tif extension, as in the example file “DEM.tif”.

  1. Import a DEM in QGIS from the Browser

Open QGIS and locate the “Browser” panel on the left side.

Navigate to the location of your “DEM.tif” file and drag it onto the main QGIS canvas.

  1. Generate Contour Lines

Go to ‘Raster’ > ‘Extraction’ > ‘Contour’.

In the “Contour” window:

  • Input Layer: Select your DEM, in this case, “DEM.tif”.
  • Interval between contour lines: Set the interval in meters. Based on the DEM’s resolution, if your DEM has a cell size of 30×30 (this can be verified in the DEM properties, under the Information tab > Pixel Size), the minimum recommended interval is 30. Although QGIS allows for a smaller interval to be defined, doing so would be technically incorrect, as the generated contours will maintain a resolution of 30.
  • Attribute name: This is the name of the field that will contain the elevation data. By default, QGIS assigns “ELEV”, but you can modify it if desired.
  • Contours: By default, QGIS will generate a temporary file. If you wish to save the contour lines as a shapefile, you should specify the name and directory where it will be saved.

After executing this process, in the following image, we can see the generated contour lines and view their values in the attribute table (right-click on the Contour layer > Open Attribute Table).

Leave a Comment