How to create Tanaka’s illuminated contours with QGis

The Tanaka’s contours are a method of displaying terrain developed by Professor Tanaka Kitiro in 1950. Tanaka called his technique the “Relief Contours Method”. However, it is usually called the “Illuminated Contour Method” or the “Tanaka Method”.

This method applies a light source north-west at a contour map. The result is a 3D style representation of the terrain. The method involves changing the width and colour of the contour lines based on their position relative to the light source: The contour lines that face the light source are drawn white while those found in the shadow are traced in black; the lines perpendicular to the light source are drawn finer than the parallels. In summary, this method gives a realistic shadowy effect to the terrain maps and allows the viewer to better understand the features of the landscape.

We will start with a layer of polylines containing isobath and / or contour lines. If you do not, already, have one, you can start from a DTM by creating a contour layer. Given the rest of the treatment, consider generalizing the contours. Otherwise a lot of patience will be needed…

In order to obtain the Tanaka’s contours, we will start by breaking down the polylines into elementary segments having only two points. For each segment we will calculate the angle of exposure to the light source. In function of this angle we will assign to each section a certain colour and  thickness : the sections completely exposed to the source, placed arbitrarily to the North West , will be white and thicker , the stretches perpendicular will be the finest, and the sections facing away from the light source will be completely black.

To break polyline, we will use the Grass command   v.split.vert that cuts the polylines at each node.


 Set the maximum number of vertexes per segment to 2.

You will have a new layer, at first glance identical to the previous except that all sections are independent.

We need to know the orientation of each section relative to the North West corner of the view. We will add an azimuth field in which we are going to calculate this angle.

Open the attribute table and the calculator field.

Enter the name and definition of the new field, and then click on the tab “Function editor”.


Enter the function to calculate the azimuth:

def Fazimuth (geometry, feature, parent):
p1 = geometry.asPolyline () [0]
p2 = geometry.asPolyline () [- 1]
a = p1.azimuth (p2)
if a <0:
a + = 360
return a

and click load. If you did not commit any error of indentation or syntax, you will not get an error message and you can return to the tab Expression:


Enter the calculus function:

Fazimuth ( $ geometry)

and you will have the result of the calculus .

Setting up the style

Now, we have everything needed to set the Tanaka style: the elementary sections and the azimuth of each section.

We will set an expression to assign a colour gradient to the sections and another to set the gradient thicknesses.

For the colour gradient, we will create an expression that will affect the most exposed sections to light, a white colour and a brightness equal to 100, and, to the least exposed a black colour and a brightness equal to 0.

Open the properties window for the -> style layer.

Click Simple Line, then open the colour definition menu and select Edit.


In the tab Expression load the following expression:

set_color_ part (
scale_linear (abs (
(CASE WHEN « azimuth -45 <0
THEN « azimuth “360 + -45
ELSE « azimuth “-45 END -180),


Click OK.

The second expression will control the thickness of the lines, affecting a thickness of 1mm to the sections across the light and a 0.2mm thickness to the sections perpendicular to it.

Open the thickness setting menu and select Edit:


In the window Expression load the following expression:

scale_ linear ( abs (abs (
(CASE WHEN « azimuth -45 <0
THEN « azimuth “360 + -45
ELSE « azimuth -45 END -180) -90),


Click OK and close the properties of the layer.

There it is!

You will find the Tanaka’s contours in your cartographic window:


Si cet article vous a intéressé et que vous pensez qu'il pourrait bénéficier à d'autres personnes, n'hésitez pas à le partager sur vos réseaux sociaux en utilisant les boutons ci-dessous. Votre partage est apprécié !

Leave a Reply

Your email address will not be published. Required fields are marked *