Tom P Worknotes

Carbon Brief: Hexagoniser

This week I spent some time working on a tool with which to create area cartograms for comparing land use.

The basic idea is: Take an image and go through each pixel in turn1 to see if it meets certain criteria, e.g. in the simplest case it's not 100% white. If it does meet the criteria then add it to a list. That list is then fed into d3-hexbin to produce an array of items, each of which comprises the coordinates for center of a hexagon and a list of pixels which are contributing to that hexagon. This data can then be rendered however you fancy e.g.

a black and white map of the UK side by side with another map of the same but this time made of hexagons

The published graphic showing how solar power land use compares with agricultural land use:

A map showing the UK and US as a grid of hexagons with solar power land use and agricultural land use extent indicated by colour of hexagon

Experimenting with overlaying different data as offset hex maps:

A hex map of the UK but each point has three overlapping hexagons in red, green, and blue

Notes

  1. I use Jimp to do this but you could do it with the Canvas API in browser and I'm sure there are plenty of other ways too.