Overview First, Details on Demand: Mapping Extreme Temperatures with Contours

Robert Simmon
5 min readJan 22, 2024

--

It’s been a week of extreme cold in the U.S., which means there have been more than the usual number of weather maps appearing in the news and on social media. Some of which are good, many of which are not.

Maps of extremes pose a unique challenge — how do you show a wider than normal range of temperatures, but still allow a viewer to distinguish between small differences? In other words, how do you achieve the first and third precepts of Ben Schneiderman’s visualization mantra:

1. Overview First
2. Zoom and Filter
3. Details on Demand

Typical weather maps address this problem — perhaps unconsciously — by using variations on the rainbow palette. In this case a flaw in the palette becomes an assett. To most viewers boundaries between colors (purple and blue or green and yellow, for example) create sharp contrast that functions as contours. In many types of visualization this false contrast can lead to incorrect interpretations of the data. But this effect does help segment temperature ranges. For example, the transition from purple to blue creates a boundary around 10˚C, and the transition from green to yellow creates one at about 45˚ C in this map from the National Weather Service:

The National Weather Service Graphical Forecast uses a modified rainbow palette to show temperature data. Visual boundaries between colors function as contours in these palettes. Courtesy NOAA.

This comes at the expensive of a certain amount of arbitrariness, since the apparent boundaries between colors aren’t evenly spaced. This is one of the problems solved by perceptual color palettes, which have been around for decades but are still neglected by some of the scientific visualization community.

Here’s the same minimum temperature data (retrieved from the NOAA National Digital Forecast Database (NDFD)) displayed in the perceptual magma palette, with a sequential scale from -30˚ C to 50˚ C:

Predicted CONUS minimum temperatures for January 21, 2024, displayed with the magma palette. The sequential palette has a limited range of brightness values, leading to low contrast overall. NOAA NDFD minimum temperature.

This removes the edges caused by false contrast, but removes detail in some temperature ranges. It’s definitely cold in the Upper Midwest, but is it colder in Chicago, Illinois or Madison, Wisconsin? Hard to tell!

In this case, the sequential palette reveals a limitation. With colors restricted to one ramp from dark to light there’s a limted amount of contrast available. And with wintertime minimum temperatures in the U.S. rarely cracking 20˚ C, only about half of that available contrast is used in the map.

Thinking outside the box a bit, why not use a diverging palette — designed to show difference from an average? Diverging palettes go from dark & highly saturated to light & desaturated colors and back with a set of complementary colors. This doubles the available contrast range:

The same data, displayed with the ColorBrewer RdYlBl diverging palette. Fine distinctions are visible through most of the color range. NOAA NDFD minimum temperature.

Better, I think. (There is some false contrast on either side of yellow (10˚ C), which could be mitigated with some fine-tuning.) In addition to having more contrast, the palette conveys a feel for the data. The use of a divergent palette works with this data in part because we perceive blue and green as “cool” colors, and yellow, orange and red as “warm” colors.

This achieves the first part of Schneiderman’s mantra — “overview first”, but what about “details on demand”? (The second principle, “zoom and filter” applies to interactive visualizations, not static ones.)

Before computers allowed us to store and display high-resolution raster data, mapmakers would use contours. These lines connected sparse data points to show spatial patterns. They’re commonly used in topographic maps, and still have applications in thematic mapping.

Could contours help weather maps simultaneously show the big picture, along with fine detail? Here’s 1˚ C contours on the minimum temperature map:

Contours derived from high resolution data tend to be visually noisy, like these derived from 2.5 km per pixel data. NOAA NDFD minimum temperature.

Oh no.

Creating contours from full resolution data (2.5 kilometers per pixel) results in a visual mess. Especially in regions with large temperature variations over short distances. To create a more readable map the contours need to be smoothed. (Skip to the end for some notes on my process)

The result is the raster data displayed below on the left, while the resulting contours with 1˚ spacing are on the right.

Smoothed temperature raster data (left) and smoothed contours (right). NOAA NDFD minimum temperature.
The final map combines smoothed contours with high-res pixels. Easy to read at a glance, but also precise. NOAA NDFD minimum temperature.

Above is the final map, with smoothed contours combined with the original high-resolution raster data. The combination is easy to read at a glance, and provides precise information when viewed closely.

Crafting an elegant data visualization can be difficult — human perception is limited, and one graphic often has to serve competing priorities. That doesn’t make it impossible! If you’re stuck on a problem, you might fond the answer in an old map. Our predecessors were overcoming these challenges long before “data visualization” was coined.

Smoothing Data

Creating smooth contours is one of those things that’s simple in concept but can be difficult to execute well. The easiest way to do it is to smooth the underlying data, then generate contours from the modified dataset. (Rather than attempt to smooth the contours themselves, which are vectors.)

There’s multiple ways to smooth a raster, but I’m using QGIS on Apple silicon which introduces some limitations. The best interactive tool I could find that could smooth while keeping the original floating point values intact was the System for Automated Geoscientific Analyses — SAGA. It’s not the most elegant interface, but it has some powerful tools.

There are several smoothing options, and after flirting with gaussian blur I decided on the resampling filter. (Found under Geoprocessing > Grid > Filter > Resampling Filter.) There’s only one option, Scale Factor , and after a few tries I settled on 12. The exact choice of scale is going to depend on the source data, display media, and output size. The filter will produce two outputs — low pass and high pass — low pass is the smoothed one. (High pass extracts & enhances fine edges.)

To make the contours I exported the smoothed data and opened it in QGIS, where there’s an implementation of GDAL’s Contour function. Mapscaping has a nice tutorial on how to make and style the contours.

--

--

Robert Simmon

Data Visualization, Ex-Planet Labs, Ex-NASA. Blue Marble, Earth at Night, color.