September 13, 2021
This post is also available on Medium.
Working with custom color palettes and digital elevation models to render beautiful topographic prints in Python
I’ve always enjoyed playing with maps.
As a kid, I would pore over the ski mountain maps of James Niehues, memorizing the trail names and verticals. His maps inspired me to hand-draw my own (fictional) ski resort maps.
For my senior project in high school, I programmed a ski resort simulation. It was basically Rollercoaster Tycoon for ski resorts. It allowed the user (me) to cut trails, install lifts, and view summary statistics for a randomly generated mountain.
This project brought me back to those early days of map making. However, instead of trying to create a realistic rendition of a fictional landscape, this project renders an actual topography with a unique color palette.
The project uses the Python elevation library to pull images from the NASA Shuttle Radar Topography Mission Global 1 arc second number (SRTM 30m) data catalog. Then, a script ingests the image, arranges the elevation data, and renders them with a contour plot.
Next, the script maps the elevation values to a color palette. Each image has its own custom linear segmented colormap (LSC), comprised of two complementary colors from Tobias van Schneider’s wonderful colors catalog. I’m still experimenting with randomly choosing the color bases as well as algorithms for selecting complementary colors.
The footer at the bottom of each image shows the colormap and the distribution of elevations contained in the image (in meters).
I’ve also created a version that turns a sequence of plots into an animated gif.
I especially enjoy the gif renderings of craters and volcanos. Here’s a reversed gif of the Nyiragongo volcano in the Democratic Republic of Congo, which erupted earlier this year and is on my bucket list of volcanos to climb.
Mauna Kea, the highest point in Hawaii, is less symmetric and more gently sloped — and less foreboding in real life too.
I lived in Ethiopia for five years. My favorite topography there, at least from the ground perspective, is the Semien Mountains, in the northwest of the country. (These photos are incredible.) It was hard to get a good contrast in the image because the elevation distribution is bimodal; it might be a good candidate for a more complex colormap assignment.
I’ve created an Instagram account @topoloco_art for these images. Follow along if you like them and DM me if you have any places or palettes you want to try out!