Demers Cartograms and Other Maps of Africa


Last fall, I came across the following visual in National Geographic:


It is essentially a cartogram showing the growth of protected areas between 1990 and 2014 in countries throughout the world. The inner square shows the area in 1990 and the outer square shows 2014, with the color indicating the growth. I just loved everything about this and thought it was a fantastic visual. And, of course, I wanted to create one in Tableau. After doing some research, I learned that this is based on a Demers Cartogram (essentially a square cartogram) and I saw a number of people who had implemented it using D3 and ArcGIS, but I couldn’t find anything like it in Tableau. Eventually I moved onto other projects, but I kept thinking about it, even throwing out the idea on Twitter to see if anyone had any thoughts on how to create it.

But, a couple weeks ago, Makeover Monday provided a great opportunity to try my hand at this visualization. The topic was the increase of internet connected people in countries throughout the world. I immediately had a vision of a Demers Cartogram of Africa showing the increase of internet usage from 2005 to 2015. So, I sat down and started working on it. Unfortunately, this was going to take some time, which I just didn’t have, so I settled for something similar, but much simpler. Here’s what I came up with. 

Note: The full visualization actually had some other charts that worked together with the map, but since the topic of this blog is the map itself, I’ve created a separate viz showing just that component



The concept is basically the same as the National Geographic visual. There are two sets of circles for each country, the inner representing internet penetration in 2005, the outer the rate in 2015, and the color represents the growth over that decade. All in all, I liked it for a few different reasons:
  1. It clearly shows the growth from 2005 to 2015.
  2. It was really easy to create with a dual axis in Tableau.
  3. It shows the true geographic location of each country. 
But I really didn’t like all the overlap in the countries, particularly in areas of the continent where the countries are small (see the west coast). This makes it really difficult to see. But, as I noted earlier, I didn’t have that much time, so I settled for it and moved on.

Replicating the National Geographic Visual
But, since publishing this viz, I just couldn’t stop thinking about it and I really wanted to try to replicate the National Geographic visual. So, when I had some time, I sat down and started working on it.

The difficulty with this visualization is that the size of each square (as determined by some metric) will also play a role in dictating the placement of the square. After seeing Neil Richards’ post on tile maps, I threw the idea out on Twitter (again). Mark Bradbourne quickly replied, posting the following image, noting “It’s a start…”


Essentially, Mark’s visualization uses squares for each country. His squares are sized by land area, so they fit fairly nicely, but the basic idea was solid as a starting point. I did the same thing with the internet penetration data, sizing each African country by the 2015 rate.


Like, Mark said, it’s a start! From here, it was just a manual effort to move things around into their proper positions, so I opened an image editor and started moving the squares around so that they fit nicely into the general shape of Africa. The resulting image looked like this. Very messy, but you get the idea.


From here, still within the image editor, I located the center of each square and recorded the x and y coordinates for each country. It was then a simple matter of placing squares in each of those coordinates in Tableau and creating a dual-axis to show both the 2005 and 2015 squares. With a little tuning of the coordinates, I’m pretty happy with the result.



So what’s good and bad about this viz? Let’s start with the good:
  1. It eliminates the overlap, making it much easier to see each country.
  2. It clearly shows the growth from 2005 to 2015.
  3. It maintains the general geography of Africa.
How about the bad?
  1. While maintaining the general geography of Africa, it’s still quite a bit off. I had to make some tough decisions on the placement of each square and, at times, countries are in quite a different position than in reality.
  2. The visualization is only able to show the change between two years.
  3. It was incredibly time-consuming to create—the manual placement of each square took forever.
  4. The work is not reusable. If I wanted to create a similar visualization using some other data set, then I’d have to go through all the manual work again since the square sizes would likely be completely different.
Creating an Africa Tile Map
The day after creating the cartogram, I saw a nice United States tile map by Matt Chambers for the following week’s Makeover Monday. You can click on the image to see the full viz.


This gave me the idea to create a similar tile map for Africa. I had seen tile maps for various countries, but couldn’t recall seeing one for Africa (I definitely had seen one and very recently…but I’ll come back to that), so I set out to create one. The trick is taking equally sized square “tiles” and lining them up in an approximation of the geography of the country or, in my case, continent. To do this, I created 54 squares in PowerPoint, labeled them with the names of the African countries and began arranging them. This is more difficult than it sounds and, like the Demers Cartogram, it required some concessions to be made about placement, especially in areas like the west coast where there are a lot of smaller countries. But, eventually, I was able to get a layout that I was happy with. I then created a grid around it so that I could easily determine the x and y coordinates for each square/country. Here’s how it looked in PowerPoint.



I recorded the coordinates of each country then downloaded Matt’s viz to understand how it all worked. Matt’s approach was beautifully simple and I was able to replicate it quite easily. Here’s the result.



Like the others, there are some good and bad things about this approach. First the good:
  1. Each country gets an equal weighting, unlike regular maps. For example, Swaziland, a very small country geographically, is not overpowered by South Africa, which is quite large.
  2. Like the Demers cartogram, there is no overlap—you can easily see every single country.
  3. Like the Demers cartogram, it maintains the general geography of Africa.
  4. It allows you to see more than just two years of data, since the area chart shows every year in the data set.
  5. Once you have the basic layout of the tiles, it’s relatively easy to create with any time series data you may have.

There is really only one major negative, which it shares with the Demers cartogram: while maintaining the general geography of Africa, it’s still quite a bit off in some places.

So, which is best? Well, I’m not really sure. Each has its own pros and cons. For this particular data set, I’d probably have to give my vote to the tile map—its ability to show all countries at once, show all years in the time series, and ease of reuse are all huge advantages.

Haven’t I Seen this Before?
After creating this, I felt pretty good about myself, thinking that I had created two visualizations in Tableau that I’d never seen before. But something was nagging me and I found myself revisiting the tile maps post by Neil Richards, which I mentioned earlier. And what did I see there? You guessed it—an Africa tile map!


Here’s Neil’s visualization (you can click on it to go to the fully interactive version). He also wrote a fantastic blog post about it, which you can find here: Where are the Africa Grid/Tile Maps?


Neil’s is quite nice (much better than mine) and I definitely wish I had seen it before I’d taken the time to manual create one myself. But I’ll chock it up to a great learning experience!

Should We Use These At All?
Before wrapping this post (sorry, I know this is a terribly long read already, so thanks for sticking it out), I wanted to ask whether or not we should use these types of maps at all. There are many who argue against unnecessarily using maps simply because you have data involving geography and I generally agree with this argument. Wouldn’t we, in this case, be better off visualizing this data with small multiples showing change over time? Is there really any value to laying it out geographically? I actually think there is—maps provide an ability to gain additional insight that could not be gleaned from more standard charts. For example, I can immediately gain some additional insight on African countries’ internet usage from each of the three maps. First, I see that the island countries, with the exception of Madagascar, have a fairly high internet penetration. I can also make the same observation of the countries on the northern coast. Finally, I can observe that the countries on the interior tend to have much lower internet usage. These are insights that could only be gained by using some sort of map.

So should we always use map with geographical data? Of course not. Sometimes maps are of very little value, but I’m personally a big fan of pairing maps with other more standard charts, providing the viewer with the best of both worlds—allowing them to analyze the data through simple, straightforward charts such as bars and lines, then allowing them to potentially gain additional insights from the map, as discussed above.

Thanks for reading!

Ken Flerlage, June 1, 2017

2 comments:

  1. Hi Ken,

    Nice work! Coincidentally I stumbled upon this the day I finally got to work doing the same thing for my client's operating areas. There are 250+ so placing by hand would have been very time-consuming. I used Excel to snap the polygon centroids to a 'best-looking compromise' grid (3km squares). That left a few squares with multiple matches, which I corrected by incrementing their grid X/Y values. That still left a fair amount of space around the larger areas, so I finished off by moving the groups manually.

    I feel like somewhere in there is the bones of a less manual approach; say one which resolves duplicates without tweaking. The goal of course is to automate the tightening of the group too, so that blocks/squares aren't disconnected from the group.

    Before starting I asked mathmeticians and cartographers on Quora for their ideas. I didn't get any solutions. One told me it's complex and requires some thought of the compromises you're prepared to accept; as you pointed out.

    Thanks for the article. It's good to know someone else is working on this.

    ReplyDelete
    Replies
    1. I did some research myself before starting, but like you, couldn't find anything. A search for "Demers Cartogram Algorithm" came up empty. Sounds like you've come up with a pretty good approach.

      Delete

Powered by Blogger.