Make Your Contours Pop Like Kitiro Tanaka — For a QGIS Beginner

Brett Peters
8 min readAug 12, 2024

--

My first attempt.

First off, I want to give full credit to Anita Graser for her walkthrough for making this cool contour effect. Please check out Anita’s blog — Anita is a talented data scientist and GIS user who has a ton to teach those of us that know…a little less.

Anyways, Kitiro Tanaka was the pioneer of this hybrid style of showing contours with some illuminated hill-shading to give a more natural visual interpretation of what the terrain looks like. He developed this method by hand in the 1950s — What a legend. We are going to save some (a lot) of time doing it in QGIS. It’s fully open source, installs right on your desktop, and is probably the most widely used and supported free carto program in 2024. I’m going to lay out the step-by-step process to get this done assuming you, the reader, have very little knowledge of QGIS. Maybe some very basic cartography knowledge is all you need. Let’s go!

Step 1 — Grab Some Elevation

First, pick an interesting spot you want to map. Preferably one with some hills. Or even better, some mountains.

You will need a Digital Elevation Model (DEM). This is just a raster (image) with a color gradient where each shade of color represents an elevation value. It should already be georeferenced to tell the program where to put it on the map. My data comes from NASA’s Shuttle Radar Topography Mission (SRTM). Please use this tool to download — It will make your life so easy. This interface was made by Derek Watkins (dwtkns.com) and allows you to quickly find and download 90-meter resolution DEMs in a snap. Or don’t use it, I’m not your mom. Find your own DEM. (USGS is another good resource in the US).

Clip of a DEM raster — Pretty…

Keep in mind that the DEM I’m using is 90-meter resolution (3 arc-second). NASA offers higher resolution 30-meter (1 arc-second) DEMs, and Derek also made a slick download interface for that here. Choose the resolution based on the scale of the map you would like to make. If the resolution is too fine, the data looks too busy on the map. If it’s too coarse, you are missing accuracy, and the map gets all pixely. 30-meter resolution should work if you map is set to 1:120,000 or less. Between 1:120,000 and 1: 360,000 scale, use 90-meter. Check the map scale in QGIS using the status bar towards the lower-right corner of the interface. Decide the limits of your map display before you start.

Side note — If your proposed map spans the limits of more than 1 DEM file, you will need to download all the necessary DEMs and combine them to make a mosaic (Look up “DEM/Raster merge QGIS” — It’s pretty straightforward)

Once the DEM is downloaded, unzip all the files into your project folder, and make sure to keep all files together. If you’re using the SRTM data, there should be a .tif file and some additional files with the same name.

Let’s add the DEM to QGIS:

Fire up a new blank project in QGIS. Make sure the Data Source Manager Toolbar is active — Go to View > Toolbars > Data Source Manager Toolbar. Click on the first icon in the toolbar — Data Source Manager.

Data source Manager Toolbar

Under Source, navigate to your DEM .tif file, hit Open, and then click Add at the bottom of the Data Source Manager window.

Navigate to TIFF DEM file

Your DEM should pop into the map in the right spot. We are in business!

Step 2— Accentuate Your Curves

Now we need to use the DEM to add some contour lines on top. QGIS makes this easy. At the top, on the Menu Toolbar, go to Raster > Extraction > Contour…

Contour Tool Setup

You will need to decide the interval between contours — I chose 100 meters. My map is set to meters, so this number will correspond to the units that you are using. Make sure this matches the DEM units or you will get some unexpected results. Feel free to leave the defaults for the remaining settings and hit Run. Hit Close to exit the window once the tool finishes.

Side note — You will see the ‘GDAL/OGR console call’ at the bottom of the window. QGIS is using GDAL to accomplish processes like the Contour tool. This is another open source tool and it’s definitely worth learning how to use GDAL on its own in the command line to work with rasters, DEMs, etc. It can be used to automate and speed up a lot of these methods. If you have any programming or console line experience I encourage you to check it out. It’s not as intimidating as it looks. Here’s a good primer to get started.

You should see a new layer called contours and a bunch of contour lines on top of your DEM image — Don’t worry about the styling for now.

Layers Panel showing the new Contours layer

Step 3—The Fancy Part — Add the Illuminated Hill Shading

Ok, so imma ‘bout to get a little technical so stick with me. If you want to just copy everything I’m about to do so you can get to the fun part, I understand. Once you do that, come back here and let’s talk about what just happened.

Step 3a — Determine the slope aspects

If you look at the first photo in this article, you will see the final Tanaka-style contours have a shading effect where it appears that an imaginary light-source (presumably the sun) is coming from a northwesterly direction. The NW facing slopes are bright white and the SE facing slopes are in the dark and black. To be able to use QGIS to add this color effect, we will need to know which direction each section of the contours is facing — This is known as the aspect.

Before this next step, make sure you save your project.

Currently, the contour lines are continuous. Let’s split these into individual segments using the v.split tool. In the Menu Toolbar, go to Processing > Toolbox to open the Processing Toolbox panel. Expand the GRASS section, expand Vector (v.*), and double-click v.split. Make sure the parameters are set to match the below image. Make sure Max. number of vertices in segment is set to 2. This will take a while — Let QGIS do its thing. Mine took about 10 minutes and I have a decent processor. Go have a snack.

v.split window. Set max. vertices to 2.

Step 3b — Adjust the edge color based on the aspect

You should have a new layer called Split by Length which is a copy of the contours divided up at every inflection point.

Zooming way in and adding an arrow line style, these contours generally have an azimuth of about 45 degrees

Let’s calculate the azimuth for every line segment in the new split contours layer. We will use this azimuth to manipulate the color of every segment along the contour in the next step.

Make sure the split by length layer is highlighted in the layers panel. Make sure the Attributes toolbar is turned on (View > Toolbars > Attributes Toolbar). In the Attributes toolbar click on Open Field Calculator (Looks like an abacus. Google it if you aren’t old enough). Name the new field ‘azimuth’ and feel free to copy the custom function:

degrees(azimuth(make_point($x_at(0), $y_at(0)), make_point($x_at(-1), $y_at(-1))))
Setup to calculate a new azimuth field for the split by length contour segments

Click OK when your finished — It should take a few moments to calculate all the azimuths, especially if you have a bunch of contours. Then, If you right click on the Split by length layer and click Open Attribute Table you should see that a new field called azimuth was calculated for every line segment — excellentttt!

New azimuth field added to the attribute table

One last bit of formatting to get the colors right…

Under the Layers panel, double-click on the Split by length layer to open the Layer Properties window. Go to Symbology, click on Simple Line at the top of the window, then click on the symbol to the right of the Color selection box as shown below.

Click on Edit… to pull up the Expression Builder. This can be used to create a custom expression to define how to display color on the contour line segments. Use the following code:

 color_hsl( 0,0, scale_linear(
abs(
(CASE WHEN "azimuth"-45 < 0
THEN "azimuth"-45+360
ELSE "azimuth"-45
END
)-180), 0, 180, 0, 100))

What’s happening here? The expression will color each segment based on the segments azimuth field that we calculated in the last step. So each segment could have a different shade — pretty cool! In this case, the formatting is set up to have the pure white for segments perpendicular to the light source (-45 degrees/NW), and then scaling the color between pure white and pure black based on the azimuth angles. The window should look similar to the screenshot below. Feel free to play around with the angle settings to come up with something new. Light sources from the southeast often give an inverted or sunken look to your contours.

Click ok and see what happens…

Step 3 — The Fun Part

Make sure your DEM is turned on and….AHH! Hopefully yours looks something like this.:

Sweet Success — But so depressing…

But this is boring, lets add some color. It’s pretty simple — Double click on the white/black band under your DEM layer in the Layer panel. It will open the Layer Properties window. Go to Symbology and set Render Type to Singleband pseudocolor and change the Interpolation to Discrete. Finally, choose a color ramp you like (I’m partial to Mako and Magma) and BAM. One last thing. Let’s blend the contour lines as an overlay with the DEM so they just melt together. Make sure your final contours layer is located right above the DEM in your Layers panel. Right click the contours layer, go to Properties > Symbology and under Layer Rendering change the Blending Mode to Overlay. Hit OK.

WE DID IT.

Magma color ramp. Hot.

Whew — That was a lot. For me….I had to write it all. Hopefully you got everything to work. Keep learning and hit me up if you have any trouble!

Please experiment with your own settings and colors and let me know what you come up with. Send me your maps — I would love to see them.

--

--

Brett Peters
Brett Peters

Written by Brett Peters

GIS/Cartography/Programming/Design. Based in Texas, but currently dreaming about someplace with more mountains and beaches.

No responses yet