Using interpolation to create a surface layer with contours in QGIS

Jeff Oppong


As a fundamental geospatial method, interpolation is one of the most crucial tools in QGIS for making complex surface layers with contours. This method uses the power of spatial data to create continuous representations that clearly show changes in elevation, temperature gradients, rainfall patterns, and other things that happen in different places.

What is interpolation in GIS?

For the most part, interpolation in GIS is a way to find unknown values across an area of geography by using known values from a GIS dataset. This method turns discrete point datasets—like elevation points from topographic surveys, weather sites, or satellite observations—into complete surface models. When these models are overlaid with contour lines, they tell a visual story that shows how terrains, climate changes, or any other topographic feature relates.

Performing interpolation in QGIS

In QGIS, the interpolation process is composed of several carefully planned steps. This GIS tutorial will guide you through finding elevation data, loading point datasets into QGIS, selecting an applicable interpolation method, creating a surface layer from those elevation points, and checking the output layer for accuracy and completeness.

Creating topographic contours in QGIS

After the interpolation process completes and an output raster surface shows the continuous spatial characteristic, the next important step is to create contours. When you look at interpolated surfaces as contours, you can easily understand how elevation or attribute changes happen across regions. These contour lines are automatically made by QGIS, and users can choose the contour intervals that best show the details of the spatial phenomenon they are looking at.

When you use interpolation and contour generation together in QGIS, you can make layers that are both visually appealing and full of useful information. These layers, full of detailed contours on top of finely interpolated surfaces, help GIS professionals, scientists, and decision-makers figure out complex spatial patterns, do more accurate analyses, and learn more about the many factors that affect our surroundings.

Tutorial Overview for creating a surface layer and contours in QGIS

For this tutorial, “add paths” in Google Earth Pro was used to digitize lines over our area of interest (San Antonio, TX, USA). The resulting file was saved in a .kml format. GPS Visualizer’s portal was used to convert these lines (.kml) into a .gpx file. The file was imported as points into QGIS canvas. Surface raster files (Grid Nearest Neighbor and Inverse to a Power) were created over the .gpx points using the elevation field with contours.

A black and white flow model with black outlined white boxes and black lines connecting the boxes to show the data and tool inputs for creating a surface layer and contours in QGIS.
Figure 1: Summary of the geospatial flow used to create surface layers from elevation data with contours using QGIS.

Using elevation data from Google Earth Pro

For this tutorial, we will be using Google Earth Pro’s offline installer or online installer: Earth Versions – Google Earth. You have installed Google Earth Pro on your computer:

  1. Launch Google Earth Pro. 
  2. From the pool of icons, select “add paths” and digitize randomly over your area of interest.
A screenshot from Google Earth Pro with red lines on top of an aerial.
Figure 2: Creating paths over our area of focus (San Antonio TX, USA) in Google Earth Pro.
  1. After digitizing over the area, set Name to San Antonio, TX and click Ok. 
  2. From places window, right-click on digitized file and select “Save place as”. 
  3. Toggle to your desired output location and set output. 
  4. Click Ok to save the digitized KML file. 

Use GPS Visualizer to extract elevation data

  1. In a web browser, open the GPS Visualizer website.
  2. Select “choose file” to upload the digitized KML file. 
  3. Click “Convert and add elevation.”
A screenshot showing the web interface for converting a file into a digital elevation model
Figure 3: Uploading .kml file for conversion.
  1. Click the download button to retrieve the converted .gpx file.  

use QGIS to add the geospatial data

Start a QGIS project. Next, add Open Street map as a base layer by:

  1. Selecting the Manage and install plugins from the Plugins tab.
  2. Type and search Quick Map services from the search bar.
  3. Click install. 
  4. From the web tab, select QuickMap services.
  5. Select OSM to import the OSM map onto the QGIS map canvas

To import the elevation data (.gpx) file into the map canvas:

  • Set Vector dataset to the .gpx file.
  • Select Add. 
  • A window appears requesting your desired vector file format
  • Select Points and select Add layers. 
A screenshot showing the data import interface in QGIS
Figure 4: Importing a .gpx file into QGIS.

Create a surface layer in QGIS from elevation data

QGIS has many interpolation methods, and each works with a different set of data and spatial setups. Different techniques, such as Inverse Distance Weighting (IDW), Kriging, TIN interpolation, and Spline interpolation, each have their benefits. For example, some can handle points not spread out evenly, others can handle spatial correlations, and others can make smooth, continuous surfaces.

Here are two of the ways you can use the tools in QGIS to create a surface layer from elevation data.

Approach 1: Grid (Inverse to a Power)

The “Grid (Inverse to a Power)” tool in QGIS is a type of Inverse Distance Weighted (IDW) interpolation. This tool estimates unknown values (like elevation) at specific locations based on known values from surrounding points. This estimation takes into account the distances between known and unknown points, with closer points usually having more influence than those farther away. The “inverse” in the name refers to this relationship: as distance increases, the influence or weight of a point decreases.

This method is particularly useful when you have a scattered set of points with known values (like elevation data from a survey) and you want to create a continuous surface that estimates values between these points.

To create a surface layer (Grid (Inverse to a Power)) the .gpx points using the elevation field:

  1. Select Raster from the menu tools. 
  2. Select Analysis.
  3. Select “Inverse Distance to a Power.”
  4. Set the point layer to gpx points.
  5. Click the Advanced Parameters from the Grid window. 
  6. Set z field to “ele.”
  7. Set the output file to your desired output name and location. 
  8. Click Run.
Screenshot showing the IDW interpolation interface in QGIS.
Figure 5: Grid (Inverse to a Power) in QGIS.

Approach 2: Grid (Nearest Neighbor)

Alternatively, a surface raster can be created using the Grid (Nearest Neighbor) algorithm or Thiessen polygon which is part of the GDAL grid utility. The “Grid (Nearest Neighbor)” tool in QGIS applies the nearest neighbor method to interpolate values for each cell of the output raster. For each cell in the output grid, the tool assigns the value of the closest input data point. This method is particularly useful when you have a set of discrete data points and you want to create a continuous surface, such as an elevation model.

To create a surface layer using the “Grid (Nearest Neighbor)” tool:

  1. Select Raster from the menu tools. 
  2. Select Analysis.
  3. Select “Grid (Nearest neighbor).”
  4. Set the point layer to gpx points.
  5. Click the Advanced Parameters from the Grid window. 
  6. Set z field to “ele.”
  7. Set the output file to your desired output name and location. 
  8. Click Run.
Screenshot showing the nearest neighbor interface in QGIS.
Figure 6: “Grid (Nearest neighbor)” in QGIS.

Applying symbology to the GPS points layer to validate the results of the surface Layer

To visualize and validate the results of our output surface layer, we will classify our gpx points. This allows us to scan the resulting surface layer to make sure the assigned elevation values of the raster data align with the elevation values of the input point data:

A screenshot showing the symbology classification in QGIS with an elevation point layer with a green gradient for classification.
Figure 7: Reclassify “gpx” points in QGIS.
  1. Right-click on the gpx layer and select properties.
  2. Select Symbology from the Layer properties.
  3. Set value to “ele.”
  4. Set the number of classes to 5. 
  5. Click Ok. 
A screenshot showing green gradient elevation points on top of a raster layer with a yellow to dark red elevation gradient.
Figure 8: Thiessen polygons and gpx points overlay in QGIS.

Creating topographic contours from elevation data 

A topographic contour is a line on a map that represents points of equal elevation. That is, everything on the ground that lies on that line is the same elevation. Contours are often used to illustrate the shape and elevation of the terrain as an alternative way for the map viewer to understand the topography of an area on a two-dimensional map.

Converting a raster elevation layer to contours in QGIS involves using the “Contour” tool, which creates lines of equal elevation based on the input raster.

To create contours from the resulting raster file:

  1. Select Raster from the menu tools.
  2. Select Extraction.
  3. Select Contour.
  4. From the contour window, set contour interval to 8m.
  5. Set resulting contour file to your desired output name and location. 
  6. Click Run.
A screenshot showing the results of using the contour tool with contours as green lines and an underlying yellow to dark red elevation raster layer.
Figure 10: Elevation raster (Inverse to a Power) of San Antonio, TX area with contours in QGIS.
Photo of author
About the author
Jeff Oppong
Jeff Oppong holds a BSc in Geomatic Engineering and currently a graduate student at Hohai University in China, where he's studying MSc. Harbor, Coastal, and Offshore Engineering. Jeff is a prolific researcher and a GIS/Remote sensing expert who aspires to be a change-agent and a renowned Engineer. Jeff Oppong can be contacted via email

Free weekly newsletter

Fill out your e-mail address to receive our newsletter!