QGIS quick tip - Tanaka Contours
Why Geographic Information Systems Stack Exchange recommends it
GIS Stack Exchange users link it when someone asks how to make Tanaka contours or shade lines by orientation in QGIS, since it walks through the full workflow.
Recommended by 2 people across 2 different months, 2018 to 2023.
What it is
A five-minute QGIS tutorial by Klas Karlsson showing how to make Tanaka (illuminated) contours. The workflow splits contour lines into short segments, calculates each segment's azimuth with a Python expression, and colours the lines by that angle to give a relief-shaded effect. It builds on Anita Graser's earlier Tanaka contour model.
What people said
Recommends TeddyTedTed · 2021-08 · Geographic Information Systems Stack Exchange · on “Calculating angles of vector polylines”
This sounds similar to Tanaka Contours which are contours that are shaded similarly to to a hillshade, e.g. contours on the north-west of a mountain are lighter in colour than contours on the south-east of a mountain. I did this myself by following Klas Karlsson's tutorial here: [this video] It's trying to achieve a similar result just for a different application. The idea is the same however, calculate the orientation of the by calculating the azimuth from start to end and then colour the lines by the resulting angle.
Recommends Jon Altschuld · 2023-08 · Geographic Information Systems Stack Exchange · on “Creating topographic "layer cake" map a.k.a. Tanaka contour in QGIS”
You are correct -- it's called Tanaka Contours. I also found this helpful video: [this video] I will mark this as solved/answered once my permissions let me in 2 days. Edit to add more details (hope this is allowed - credit to anitagraser.com for the functions and process). The solution to doing this in QGIS is to first split the contours into smaller segments using Split or v.split tool. Then, you can use the Python Field Calculator to calculate azimuth of each segment using the following function: p1 = $geom.asPolyline()[0] p2 = $geom.asPolyline()[-1] a = p1.azimuth(p2) if a < 0: a += 360 value = a After that, you can color the contours based on a function using the azimuth. The function below
Cites Chris Medyna · 2018-03 · Geographic Information Systems Stack Exchange · on “Trying to Create Tanaka Contours in QGIS”
I am following a tutorial with which to create Tanaka contours from: Tanaka Contours [this video] . I used contour with the default 10 increments setting. Below are the raster and resulting contours. [LINK] [LINK] Following this I used V.split to break up the segments and used max 2 vertices. I then used this equation in the advanced python calculator to get azimuth: [LINK] At which point I styled the resulting calculated layer with this expression: [LINK] Here is the result of that: [LINK] Clearly, I'm doing something wrong. I just have no idea what that would be. Can anyone shed some light?