Skip to main content

D3 Map Projections Morphing

Australia in Australia
Map of Australia mapped on Australia
We had a very good geography teacher in high school. He taught us how one should be sceptical and keep an open mind in science (using an anecdote about a scientist proposing an alternative to the theory of tectonic drift). He was also the first person I met that had surfed the Internet - or whatever it was called back in the day. But the thing he showed me the importance of, most relevant to this blog post, is the choice of projections of world maps. You know, the whole 3D globe to 2D piece of paper business. Mapping, qoui. Some are just more equal than others.

You see, yesterday evening I decided to finally take a closer look at the D3 visualization library. A couple of the demos on the d3js page, notably the excellent animated show reel and some of the mapping examples, made me think of discussions I have had with colleagues and friends on map projections. I wondered if animating the transition from one projection to another would help show the problems with certain (overused) projections (like the omnipresent Mercator (we are no longer colonialist seafarers, now, are we?)).

I created a quick hack, based on some example code from the d3.geo-library, added some simple selection box controls, and transition animations, and voilà: http://bl.ocks.org/4742558 - an interactive animated map projection demonstration tool. Try switching between Mercator and some (more) area preserving projection (like a cylindrical one) and you'll catch my drift. (Word of warning: some projections tend to crash the browser - probably because of my naïve implementation of swapping between them. (I'll try to take out  the misbehaving ones - or at least flag them.))

The source code behind this is displayed prominently below the map if you follow the link above. (Another word of warning: JavaScript is not exactly my mother tongue.) (Al)so, there are several weird features that I've been to lazy to take care of...

I revisited this hack today, though, and made it look neater (with blue water - that is for you, Seb) - and the code is (maybe) cleaner, but morphing between projections looks more messy - probably due to my limited understanding of both JavaScript and D3: http://bl.ocks.org/4739921

Bottom line is: I'm really excited about the potential of the D3 library! Thanks !

(And I do of course realize that not all of these D3 projections were made for world maps...)

Update: I guess I should go through the projections one by one and set the correct scale, so the maps keep their general size better. Also, it could be interesting to pan in a more reasonable manner. (Especially the orto-projections.)

Comments

Popular posts from this blog

Using a Raspberry Pi as a MIDI USB/5-pin bridge

In my constant... need... to get everything music instrument related to communicate with each other, I wanted to look into ways to get some of my keyboards/synths with only MIDI over USB to talk to devices with regular good old-fashioned 5-pin MIDI ports from the eighties. Cables! First I had a quick look at off the shelf solutions. The most interesting one being the Kenton MIDI USB Host – providing MIDI host functionality for USB devices as well as regular MIDI in and out in a small box. Unfortunately it is rather expensive (~125 €) and a reliable online source warned me that it was not entirely stable in collaboration with my OP-1, so I started thinking of more... home-grown solutions. I decided to try to use my old Raspberry Pi and see if that would serve as a USB host with a borrowed MIDI USB adapter. (Thanks Simon.) A cheaper, and, as an added boon, a nerdier solution. Step 1: Get the USB MIDI device up and running This was the easy part. The device I have been lent ...

Fix your rapid blinking Marantz SR-6004 using nothing but 3 fingers - and a thumb

A couple of years ago my (most of the time excellent) Maranz SR6004 acted up. It did't want to turn itself on. Properly. Just stood there and blinked rapidly. Its little red light that is. At me. The solution was so simple that I didn't bother to write it down as I was sure to remember it. Alas, no. Some weeks ago it did it again. (Can it be the heat?) Just stood there blinking rapidly at me. The manual just said - as it said last time around - that it was time to return the unit to it's maker. Or similar. Some googling led me to this page:  http://www.allquests.com/question/4056803/Marantz-XXX4-Series-Failure-Issues.html  The technical term for what I had experienced seems to be "The Pop of Death". Aïe. But!, humongous letters said: YOU CAN SOMETIMES RESET THE UNIT BY PRESSING SURR MODE, CLEAR AND EXIT SIMULTANEOUSLY And so I did. And so it was fixed. And all was well. (And now I have written it down for the next time.)

Add overall lesson timing to video listings on Coursera

Marché de La Rochelle HDR  Probably about two years ago - when taking Andrew Ng's excellent "Machine Learning" MOOC, Johannes sent me a piece of JavaScript that populated the video lists with overall time per lesson just by pasting it into the URL-thingy in Chrome. Magic. Today when I sat down to start the course on "General Game Playing" that I have signed up for, but, alas, not (yet) found much time for, I thought of that piece of code and wondered if I, with my new knowledge of JavaScript, could whip up something like that. (Also I couldn't find Johannes' original one.) I quickly hacked together something this afternoon over a flat white in a hipster cafe here in Lyon. And lo and behold it worked. Then I extended the functionality to also show minutes and seconds of unwatched video - as well as total overall counters for the entire course. Now each lesson heading reads "Lesson N - Name [time remaining/total time]" instead of just ...