‘Painting’ terrain in QGIS

I’ve been making boring maps for a lot of years, mainly for research (this is about my pinnacle for the last while). In general these are vastly under-utilising a pile of analytical tooling available in modern map rendering systems. So more recently I’ve been exploring. The MH370 map piled in a lot of techniques I hadn’t used before, and the photo centre map for remotely piloted aircraft tinkered with some more.

This story is about working with terrain data. As part of a 30 day map challenge in 2019, I prototyped a ‘Blue Tasmania’ map which consumed a lot of time working with GDAL‘s Terrain Ruggedness Index (TRI), part of the gdaldem toolkit. I also started tinkering with TRI in terrain which seemed wonderfully suited: the western Blue Mountains in Australia:

TRI around Newnes, the Wolgan River and Old Baldy, New South Wales, Australia

Visualising terrain seems taken over by amazing, complex renders using 3D modelling software. These are incredible – and inspired the question ‘how can I make terrain renders which are awesome, in simpler ways?’

In turn, this question led to the Blue Tasmania map and then this dive into TRI. Looking at the image above, it’s close to what I wanted but not quite. TRI highlights the clifflines I was after (the major topographic feature of this part of the world); and like the MH370 map and Blue Tasmania, layer rendering effects help to combine it with elevation data which would otherwise be difficult to read without adding contours.

…it just didn’t ‘pop’. It’s nice, but kinda boring and characterless.

This next image – on the other hand…

A larger chunk of the western Blue Mountains

This one has some fortitude and style. It’s based on ASTER GDEM v3 elevation data instead of lidar, it still uses layer blending to combine elevation and TRI. Aside from bolder colours, why does this one pop?

…because it has a better colour scheme (grey on yellow was never going to get wild); and I’ve deployed multiple layers of TRI here. It’s actually stunningly simple!

The method section

To make this map I started with the ASTER GDEM v3, available via the USGS AppEEARS system. It’s coloured by elevation, black low and white high:

Turning the brightness up a touch gets us ready to make the terrain a ‘background’:

Next, TRI is computed using the QGIS processing toolbox and added to the map:

Make sure you set the elevation data you’re using as the source, save it as a file and add it to the map.

The first TRI layer is coloured with the standard blue palette; range limited to ‘mediumly-rugged terrain’ Once added, render mode is set to multiply:

Because of layer rendering magic, lower values still allow the background terrain to shine through, and higher values (more rugged) are more intensely coloured.

I then chose to turn things down a little using global opacity:


It’s still kinda ‘meh’ at this point. To try to fix that I added another TRI layer for ‘really rugged terrain’. Duplicate thre layer you just made, use a black and white colour palette and limit to the highest TRI values. Again, render mode is set to multiply:

So we’ve de-meh’ed the map now, highlighting the steepest terrain with a lick of darker ink. Here’s the map with ‘just the rugged-est terrain’ visualised:


…and that is the whole process! We end up with a map that almost looks ‘painted’; wholly based on a fairly simple measure of variance in a patch of terrain:

The objective of ‘making a pretty map of cliffy terrain’ has been met!

The key part of the process is layering up TRI, with each layer tuned slightly to a different part of the index and using different colour ramps to help make the ‘painted’ effect.

…and it’s all made using a really simple chain of built-in QGIS tools. I particularly enjoy the ‘ink brush’ look this has achieved, a lot like my own ‘why draw one line when I can draw many’ style of sketching…

Can we do anything else, other than look at it?

My initial goal was to really make a pretty poster than I could stick in a web store and sell prints from. However, this technique has uses!

Here, I’ve added an aerial photography overlay from the New South Wales Government (pre-2019/20 fires) and in my view it really works to make the clifflines / rugged terrain readily apparent. In this iteration, the lower resolution of the terrain data is also readily apparent!

So I grabbed some lidar-derived elevation the NSW Government has made available via Geoscience Australia as input terrain – and oh my…

The strong cliffline in the upper middle of the image is ‘old baldy’, with an upper and lower cliffline. I’ve spent a few wonderful days climbing the 100m upper cliff, complete with some fun near-epics and abseiling off by torchlight. It’s an impressive wall of rock!

At this scale, applying TRI to higher resolution really makes these clifflines pop out.

Here is where lidar and satellite altimetry meet:

And here is an overview showing both lidar and satellite-derived terrain at larger scales. The patch of lidar-derived terrain still works well from afar:

The background stuff

GDAL uses the implementation of TRI given by Margaret Wilson and colleagues in a 2007 paper titled ‘Multiscale Terrain Analysis of Multibeam Bathymetry Data for Habitat Mapping on the Continental Slope’. It is the mean of the absolute differences between a central pixel and all neighbouring pixels – which is a way of describing variability in regions about each pixel in an elevation map . Where elevation changes rapidly, TRI will be high. Where it doesn’t, TRI will be low.

In Wilson et al (2007) it is explained as a tool for habitat delineation. For the terrain I’ve used in the Blue Mountains, TRI is pretty much functioning as an edge detector! In other regions (for example this image, near Tromsø in Norway using the same technique), its easier to see that TRI can be used to discriminate between terrain types:

GDAL’s implementation uses a single-scale TRI – using the immediate 8 neighbours of each pixel to compute ruggedness. If a multi-scale TRI is needed, please walk down the list of contributors and hire one of them to implement it!

I’m somewhat curious about whether the neighbourhood variance (average of the squared differences from the mean in a neighbourhood) is more or less functionally the same as a TRI – perhaps a normalised version of either would also be good to play with. However, I defer to statisticians and the long line of researchers leading to, and building on the work of Wilson et al to answer those questions…

Whatever your use case for TRI, I hope this walk-through helps you find a way to make your maps more wonderful. If you just really like the map, can also purchase prints in the Spatialised store!

The sales pitch

Spatialised is a fully independent, full time consulting business. The tutorials and write-ups here are free for you to use, without ads or tracking.

If you find the content here useful to your business or research or billion dollar startup idea, you can support production of more words, ideas and open source geo-recipes via Paypal or Patreon; or hire me to do stuff; or hire me to talk about stuff; or just give me a seat on your advisory board and a 1% stake. Enjoy!