Monday, 18 August 2014

Just an A

Alberto Cairo's great blog post on the issue of constructive criticism and snark (as in snide remarks) turned into an interesting discussion with some really good contributions. Muggins waded in because I was mentioned in the original post and thought I had some comments to share...including a throwaway line about my first map getting an A+ at University.

And my, didn't the inevitable people enjoy that nugget and wade in with some snark of their own. Curious that because they're the very same people who purport to hate anyone throwing snark in their direction.

Anyway, I've got to hold my hand wasn't an A+ I got, I dug out the work and dammit...just an A. So just for your enjoyment here's the cover of my very first map from University in 1989.

It was an A5 brochure designed to support the Monsters of Rock concerts at Castle Donington near my home town. When opened you got the layout of the concert site and all the important information...such as 'bar' being the first legend item:

The copy I have is getting a little tired and the ink has smudged but the map is still fairly legible. All hand drawn on drawing film with computer generated lettering positioned by hand, symbol design, drawing pen on film etc etc. Lots of work went into this little map.

The back cover had smaller scale location maps:

And here's my lecturer's grade and feedback of which I remain very proud. His name was Roger Anson...a damn fine man and a brilliant lecturer. I was privileged to have learnt cartography from him and his colleagues Mike Childs, Stuart Granshaw and John Robertson.

I've always been particularly proud of his last statement. I always have been someone who tries and helps people do better work. It's why I eventually went into academia and enjoyed helping my own students aspire to be better and to achieve their own goals. It's why I moved to work in the U.S. to help the company I work for make better products to help people make better maps. It's why I take a full and active part in the community with this somewhat snarky blog and a whole load of other far more sensible and unsnarky work.

I also dug this gem out too...not one of my better pieces but I think it was piece of work set to try and create equal looking qualitative shading schemes on an early Mac using just lines. Tough project. Terrible map (by today's standards?)

So there you have it friends...or if you're not a friend and just someone who thinks they know me through my tweets and this blog then maybe we'll get a chance to meet one day and share some constructive ideas.

Sunday, 17 August 2014

LyricMap: Born in the U.S.A.

Number 3 in an occasional series of LyricMaps is loosely based on Bruce Springsteen's Born in the U.S.A.

A hot spot analysis (using Getis-Ord Gi*) in GIS defines statistically significant neighbouring areas that are above or below the global average. Stronger red hot spots define neighbouring areas that have either more or less people born in the U.S.A., compared to the national average. More red (a hot spot) equates to more people born in the U.S.A. and more blue (a cold spot) equates to more people not born in the U.S.A based on data from the 2010 census. Areas shaded in neither blue or red have no statistically significant populations born in the U.S.A. or not so they are similar to the national average.

The counties in New Jersey, Bruce Springsteen’s home state, are all cold spots with more people not born in the U.S.A. unlike Bruce.

Data analysis by Madeleine Parker and Linda Beale. Map by Kenneth Field 

Voronoi treemap maps

The New York Times flexed their considerable graphic muscles this week with some superb interactive charts showing how the population composition of U.S. States has changed over time. You can check them out here.

They really are beautiful graphs. Simple, clean, lots of 'white space', good hierarchy of typeography and excellent use of colour linking to a small map legend. They even provide some additional discussion and as you hover over the graph the intersection between time period and place gives you some basic metrics.

They then added to this excellent set of graphs with an interactive map of the same data; a new kind of map that they're calling a voronoi treemap map.

The data has been pivoted so the focus is on space in contrast to the focus being predominantly on time in the graphical representation. You can pick one of three time slices to explore how patterns vary spatially. The hovers still work extremely well and one click zooms to a state...great user interaction and experience. The benefits of looking at a map instead of the graph are that it should support the visual comparison from place to place. That's not something you can do with the graphs with each one only illustrating a single state...but what about the map?

What fascinated me about the map is the technique. The use of voronoi polygons to sub-divide space into a tesselation of shapes that represent different proportions is nothing new. Treemaps are also nothing new and have been used very successfully as a sort of area-based cartogram. Here, though, NYT have combined the techniques and used a bounding space (each State) inside of which space is tesselated based on the proportion of the population from different other places. It's not something I've seen before and it's always worth looking at experimental cartography.

Does it work?

I like the idea and I like the attempt at trying something new. However, I see two issues that I feel undermine the map and what it offers.

Firstly, the voronoi polygons are only proportional intra-state and not inter-state so you get polygons with the same percentages of populus that are visually quite different to polygons with the same value in another state (see Texas compared to Oklahoma state-born residents, both 61% but one visually dominates). The point about putting anything on a map is to create visual comparisons and the voronois are, effectively, unequal in area from state-to-state so incomparable visually. The relative areas of each state underpin what we see. Since we're visually comparing one place to another and forming a mental picture at first glance Texas would seem to have a larger number of State-born residents than Oklahoma. I'm not sure there's an easy solution unless you turn the voronois into a population-equalizing cartogram (e.g. the Gastner Newman) to account for the different sized areas. It'd certainly be interesting to see what happens if they were equalised by population or area.

My second observation is really just about the design and layout. In each state the surrounding voronoi fragments seem to be randomly positioned around the central voronoi polygon that represents the people born in-state. If you look at the small legend map on the graph version you see that the orange, green, blue and pink colours are used to suggest west, south-west, north and north-east. It would have been nice if the surrounding voronois were arranged so they sit on a compass direction to where the state actually exists. So for each state the oranges would always be on the left, the blues to the north etc. This may bring some sense of structure to the map and avoid the somewhat random positioning we currently see.

Overall I think there's a lot of merit in this new map technique but it probably needs some more thinking to make it really useful.

Thursday, 14 August 2014

Web Mercator and Comparisons II

[this post has been updated]

Not a week has gone by since I posted about the problems of comparing areas between places using Web Mercator. Here's a 'simple map' (author's phrase) that allows you to compare Gaza with other places on the globe. The interactive version is here [map now corrected].

Terrific idea...take the outline of Gaza and allow people to enter a place they are familiar with in order to better understand the size of the place in comparison with somewhere they know.

Except the basemap is Google's Web Mercator (other Web Mercator basemaps do exist) and the shape has been drawn across the map. 

Only places directly on the equator contain no areal distortion on Web Mercator. Gaza lies at approximately 30 degrees North so there's already considerable distortion in the area of Gaza on Web Mercator.

If you then pan and zoom the map, the Gaza shape remains the same size and shape (at each scale) wherever you go to on the globe. It does not get reprojected as you move across the map and that's a huge cartofail fail regardless of the projection. As we saw in my previous post by looking at Tissot's Indicatrix the size of areas gets massively distorted across Web Mercator. The shape of Gaza would be no different.

Unfortunately this is not accounted for in this map. A classic case of ignoring the impact of map projections. Unless you compare Gaza with somewhere else that is exactly 30 degrees North (or South) then you're comparing one distortion with another and the relative scales of the overlay graphic and the basemap are out of sync with one another. The map, then, is utterly useless and, worse, people look at it and believe that it accurately portrays the stated aim. It doesn't.

A lot of people say to me that the science of cartography has little relevance anymore and it's all about form over function, or function over form and that rapid hackups that buck cartographic convention are healthy. If those that (a) build this sort of cartofail and (b) those that unwittingly consume it are happy then there's no hope. Unfortunately experience shows people tend to be happy in their ignorance and prefer their own facts over fact itself. If you make maps, learn some's really not that difficult but no amount of clever coding allows you to ignore the basic science of the very thing you're coding. Use your coding skills wisely and learn some domain knowledge to give those skills real power and substance.

ht to Ryan Cooper for alerting me to this map and for correctly identifying the problem.

UPDATE: Something unexpected happened after Ryan Cooper, Ralph Straumann and I tweeted and blogged about the problems of this map. The author Ahmad Nassri got in touch. I was primed for the usual volley of abuse but unlike the majority of people who seem to take offence at having a critique of their work plastered online pointing out major faults, Ahmad took the opposite view. An online conversation took place in which he was grateful for someone identifying a shortcoming and eager to learn of the cartographic 'problem', he sought help in figuring out a way to overcome it. His reaction was refreshing and a credit to his desire to get his work 'right'. Within a couple of hours he had figured out a way to control the shape of Gaza using the Google Maps API geodesic parameter so that it would draw geodesically as you pan and zoom around the globe. It doesn't get over the problems of Web Mercator but it does make his Gaza shape scaleable across the globe to work in sync with the projection. Both the map and the shape of Gaza are now distorted in the same way which is as much as can be hoped for if Web Mercator is the basemap. The map now does what it claims, it gives people the correct basis for visual comparison but most of all Ahmad illustrated a willingness to take on board our comments and correct his work. He should be hugely commended for his reaction. Win win!

Saturday, 9 August 2014

Web Mercator and Comparisons

Getting the curved surface of the earth onto a flat map (paper or screen) requires a map projection. The reason so many projections exist is because there is no perfect projection and they all contain distortions which affect area, distance, shape or size...and distortions vary to different extents across the map.

While for most people, the often complex mathematics of transforming locations to the map is beyond their expertise it's important to pay some attention to the choice of projection. Choosing an appropriate projection is vital to ensure that the inherent distortions don't wreck the very purpose of your map.

Let's look at one example...say, for instance, you were wanting to create a map which allowed you to compare the areal extents of different cities across the world. You might want to see how one city compares to another in terms of the amount of green space, or the population density in urban areas. The one thing, the only thing, you need to get right is the choice of a projection that supports visual comparison. You need a projection that does not distort area...because area is the one property of the map that supports the cognitive process of visual comparison. Let's see this in action...

We can see what happens to distortions when we overlay Tissot's Indicatrix on the curved surface of the earth. The Indicatrix is simply a grid of equally sized circles (on the globe) which are a very familiar shape which makes it easy for us to see what happens when it gets distorted through projection. When projected, the grid of circles of equal size, shape and area are distorted which gives us a clear indication of what happens to the real geography that gets projected at the same time.

Tissot's Indicatrix on a globe:

Here's what happens when we project to Web Mercator, the default for web maps:

Web Mercator preserves angles (which is why the circles retain their shape) but distorts size, and, fundamentally, area. It's great for navigation (its intended purpose) but dreadful for most other purposes.

Now let's compare the two cities marked on the map...Oslo and Singapore.

Oslo is at 60 degrees North. Singapore is pretty much on the Equator at 1 degree North. There's virtually 60 degrees of latitude between them and looking at the two Tissot Indicatrix circles they fall in you can see the distortions that Web Mercator creates in the size of area between the two places. If you examine the size of the two circles you find that the Indicatrix around Oslo is approximately 75% larger than the one around Singapore.

Let's have a look at the impact on a real map. The following maps are on Web Mercator and both at a scale of 1:250,000. Oslo on the left, Singapore on the right.

Now let's look at exactly the same map but projected using a Cylindrical Equal Area projection. I've switched the standard parallel to 60 degrees North for the Oslo map just to ensure the shape isn't distorted compared to Singapore but areas are consistent between the two maps. Now compare Oslo with Singapore.

Oslo is now shown at the correct areal extent and size compared to Singapore. The distortions you see in the size of text etc is simply because the map tiles used to display this were originally in Web the fact they are now reduced in area by about 75% actually results in the map looking like it's shrunk. It has! It also shows how much Web Mercator tiles are distorted in terms of area the further from the equator you go.

The answer...pick the right projection for the right job. You can go beyond Web Mercator on a web map so it's just a case of figuring out how to do it using your technology of choice. If you're going to be comparing areas either for city comparison or for thematics you really do need an equal area projection unless all of your cities sit on the same degree of latitude. If not, you're literally pulling the wool over the eyes of your map readers and they leave with a totally distorted impression of the themes mapped.

Next time you look at a map whose purpose is comparing places just pause to check the projection and then make your own decision whether you can trust what your eyes are telling you.

Friday, 8 August 2014

Three dee thematics

I've always been intrigued by the potential for 3D in thematic cartography but it is that much harder to get 'right' than 2D...and look at what a mess many get in when trying to make even the most basic of 2D maps.

We see the world in three dimensions because we were given two eyes and stereoscopic vision. That gives us depth perception. In making maps on a flat surface (paper/screen) to mimic how we see the world we have to go beyond our basic palette of visual variables and symbol encoding and play with additional variables. We have to make the eyes see the third dimension.

The standard way of achieving that is to make the map in a perspective view...near things are closer to the eye than further away things. We can accentuate this by perhaps adding a sky in the background (to mimic a far off horizon) or add in haze to diminish objects further away in the same way as haze affects our view in reality. This generally works well for maps of the natural world....mountainscapes and street scenes for instance.

But this approach doesn't apply equally for thematics because the principle objective is to create a consistent view to support comparisons across the map. The perspective view does not support that cognitive need.

Take the following example in which the Obama/Romney 2012 percentage share of vote election results are shown using a diverging hue colour scheme. Increasingly blue = Obama, Increasingly red = Romney. purple = equal share.

What the map doesn't show us is how many voters there are in each county which might help us better understand the reason Obama let's whip it into 3D and use extruded areas to show the number of voters.

Simply placing the choropleth on a virtual globe and extruding areas is a very common approach to 3D thematic mapping but it's bloody awful!

The perspective view seriously compromises our ability to compare the height of our extrusions like-for-like. The foreground is nearer the eye than the background. Worse, the curvature on a virtual globe alters the shapes as well so we're seeing all sorts of distortions that our brains have no hope of disentangling. The “fish eye lens” effect mean each prism is viewed from a different angle than its neighbors, making comparison just a little bit harder as we have to mentally account for these differences in our estimates. It's hard to judge the height of something when you are staring directly down at it too...look at those areas in Florida. This matters because height is the visual variable that does the “work” in this map—it’s how the data are encoded visually.

Here are a couple of other examples that make the same mistake. First up, capacity by energy source in the US:

The map tells us (yes, it the blurb at the top) that we're seeing a clear stratification of energy sources across the US. Are we? I just see a map whose visual centre is focused on the sparse areas in the middle (the least interesting datawise) and a load of 3D columns of various colours fading off and disappearing over the horizon. It's like the data is running away, off the edge of the map, scared to be party to the horrific map it's been placed on.

In this example, 3D kills the map. The intent to 'look cool' by using a curved virtual globe destroys any hope of the reader being able to see any patterns. Look at the large orange bar in Arizona toward the it taller or shorter than the one you see poking out above the skyline in the north-east? Who knows...but I bet they're about the same value. And stacking colours on top of one another makes the top colours more prominent anyway. Who knows what's hidden from view in the east. And finally, what of the colours...nearly 30 of them. The map reader has no hope of figuring out the difference between distillate fuel oil and petroleum gas...or geothermal and purchased steam.

Another I saw recently appeared on a T-Mobile advert:

 The title is meaningless. The legend shows us T-Mobile's data network usage in the slightly darker pink among their partner networks in slightly lighter pink. OK - it's an advert. The point is to show complete nationwide coverage and they wanted something a little more visually striking than a choropleth so...threedee it! Except compacting the map by putting it on its side and tilting it so dramatically makes it impossible to see where all those columns actually sit. And what's the vertical scale? It seems that the base height is actually extruded a fair bit to give the impression that perhaps even a small usage/coverage is a little larger than it might actually be. The map is designed to obfuscate reality because it's an advert...but if we wanted to make sense of the actual distribution the 3D approach kills it.

And here's an example from Andrew Hill which you really have to see as the web map here to fully appreciate its full three dee gory glory:

Andrew does some great work and pushes what technology allows. He also brings a fresh perspective on making maps that pushes the boundaries and challenges long-held principles. That's great in many ways but there also has to be a sense of understanding when the outcome doesn't stack up cognitively.

The hexagons have been used to bin the point data (911 calls) and height of the prism relates to quantity. All well and good to this point...but try and compare height relative to an absolute vale or relative to one another and you quickly become disoriented. Technically this is cool, no doubt. Cartographically it's questionable...very questionable, because it doesn't support the necessary cognitive processing needed to understand the pattern.

I did enjoy his twitter banter though...

So can we make better 3D thematic maps? Yes. You simply need to use an isometric projection which distorts the plane on which your map sits to make the scale equivalent across the whole map. Here's the election data on an isometric base:

Now unless you're going to provide the ability to rotate and interact with the map, you're going to still suffer the problems of occluded data but at least here each column is in the correct relative proportion to one another. We can accurately compare heights across the map and make sensible inferences. The interactive version is here which supports rotate, pan and zoom...though be warned that another difficulty with interactive maps is the constant ability to rotate, pan and zoom means we lose track of our visual anchors and this generates short-term memory flushing. In other easily forget what you just saw and that means you lose the ability to build a comparative picture.

There we go...some thoughts on threedee thematics. In short...stick to 2D unless you're prepared to go the extra distance to deal with the additional problems 3D creates.

The reason for cartography

If ever there existed a reason for cartography then this is it. Possibly the year's worst map so far.

It was on the New Republic web site today as a map to accompany a story by Jonathan Cohn.

There is nothing about the map that is correct...actually, that's a lie...the projection (Albers equal area) is correct. The data, however needs to be classified, it needs to be normalised and it needs a sensible, sequential colour scheme.

To be fair to the guy he's taken some serious social media heat and redrawn the map. The data is now classified and he's got a decent shading scheme. Still not normalised it's impossible to make any sensible visual comparisons.

Is the availability of tools to allow anyone to make maps a good thing. long as those same people appreciate that if they are going to do so they are obliged to learn how to avoid the basic mistakes as a bare minimum. Cartography exists to guide people. Yes, there are basic cartographic rules but they are designed to tell map-makers how people read maps and, therefore, how to design them to make sense and be useful. If you're going to make a map of your data, ignore cartography at your peril.

And as I type...Steve Koczela has re-worked the data into per capita so here is a 'correctly constructed' map. Good projection...classified sensibly, decent shading scheme...and normalised data so we can compare like-for-like across the map. All rise!

So there you go...the first map shouted Pennsylvania and Alaska (bright colour catches the eye). The second map told me Texas and Florida were screwed (darker colours = more). The final map...Mississippi by some margin from North Carolina. Texas isn't that bad after all.

Finally...a small parting shot...with about half the states missing data...maybe this would look far better as a bar graph anyway?

UPDATE: Cohn has updated his web page to include a per capita map. As this blog is set up entirely to point out cartographic mistakes (often with a little of my cursed British humour thrown in which I know isn't to everyone's taste) it's a welcome sight to see people respond and correct their efforts where necessary. I admire Cohn for taking the views of this commentator, along with many others, into account and correcting his mistakes. It's encouraging that some actually do want to learn and move forward with their work. There's also a nice write-up of the need for constructive critisism spurred on by this map over on Alberto Cairo's excellent blog.