๐Ÿ†• Creating a Digital Terrain Model (DTM)


A DTM is vital for all sorts of data analysis and visualisation.

DTMs are an incredibly useful tool to have in your geospatial arsenal. For example they can be used for: The creation of 3D visualisations that will help in applications like environmental studies and town planning; Slope modelling for avalanche risk or erosion analysis; Route planning or road network design when you want to find the flattest route between two points or are planning to build a transport network; Line of sight (view shed) analysis; Water runoff plotting and flood risk analysis. And many, many more applications.

Ordnance Survey provide height information in the form of contours and spot heights in the height products Terrain ยฎ 5 and Terrain ยฎ 50 (Terrain 50 is open data and freely available) but there is also another format that Ordnance Survey Terrain 5 and Terrain 50 height data is supplied in; ASCII grid. An ASCII grid is like a raster image, but instead of a pixel representing a colour value as it would in a raster image, the pixel represents a height value in an ASCII grid.

What do you need?

  • A GIS. For this tutorial QGIS 3.22.4 โ€“ Biaล‚owieลผa is used

  • ASCII grid data. For this tutorial the following 12 tiles from OS Terrain 5 are used:

  • SU33NE; SU33NW; SU33SE; SU33SW; SU34SE; SU34SW; SU43NE; SU43NW; SU43SE; SU43SW; SU44SE; and SU44SW;

  • The OS Maps API light_27700 mapping was also used to add some geographic context


Start a QGIS session.

Because we are processing a small area of data we can use a GIS for this so start your QGIS session and load the 12 tiles. There will be several different formats of data that will arrive with the ascii format, choose the ones that have the .asc extension and load them. Once this is done your QGIS session should resemble this:

What we want to do now is merge all of these tiles into one. However, this will create one quite big file so we'll need to compress it too. Fortunately QGIS has a lot of GDAL* tools preloaded as handy GUIs that we can use for this process.

Click on Raster > Miscellaneous > Merge

This will open the following GUI in your QGIS session but select the input layers last otherwise you won't be able select where the file saves or what compression to use!!

  1. Browse to a location that you want to save the merged image to and give it a name that explains what it is and that you'll remember. Save it as a tiff file.

  2. Select the compression from the Profile bar, select High Compression

  3. Now we can select the input layers, choose all of the imported .asc files.

Before selecting the input layers your GUI should look like this:

When you have selected all of the .asc files in your QGIS session click Run

When the process has finished (it may take several seconds depending on the number of tiles that you've selected) you will see the log file window which you can close.

Your QGIS session should now look like this:

Adjusting the local DTM height values to match national values

While this now looks very pretty, the height values that are present in this merged DTM are for the range of values that are present just for this small area and are not reflective of the range that would be present nationally.

We can remedy this by right clicking on the merged DTM in the layer pane and adjusting the Min and Max values in the Symbology tab to match those of the original .asc files:

The minimum value of 25.89 and maximum of 158.87 are those just for this small DTM, change these values to -20 and 1347 to match those of the original component .asc files. The DTM will now agree with national values so any measurements taken from the merged DTM will agree with any other tiles across Great Britain.

These national value ranges can be found under the tile numbers of the .asc file in the layer pane

The image of the DTM will now look fairly dark again but the image can be altered by right clicking on the merged layer, selecting the Properties and then adjusting Brightness and Contrast:

And that's it! You now have a DTM to use in this QGIS session!

* GDAL, or The Geospatial Data Abstraction Library is a software library that many GIS can use which allows for the reading and writing of raster and vector geospatial formats. It also allows translating and geospatial processing, reprojecting, moasaicing and tiling. It is released under the permissive X/MIT free software licence by the Open Source Geospatial Foundation. More information can be found here: https://www.osgeo.org/projects/gdal/

Last updated