inchworm

inchworms

Summer of Coding, one inch at a time...

Germany ist Grosser

inchworms -

Today we were feeling ambitious. So after finishing refactoring our Sinatra tests, we decided to take our D3 learnings and make some maps of Europe.

First we needed to find the shapefiles for our chosen countries (Carla chose the Czech Republic, Anja went with Germany). We found them on the Global Administrative Areas website.

Then we had to convert our shapefiles into GeoJSON files, a format that D3 can work with. We did this using something called gdal, then running the ogr2ogr command on our downloaded .shp file (details of exactly how to install this software can be found in Interactive Data Visualization on p233).

Once we had this the next challenge was to work out how to properly use the D3 projection function. We didn’t realise it was important to pass latitude and longitude coordinates for where the centre of the map should be (in Anja’s case, 50 and 10, in Carla’s 48 and 15). From there, scaling and colouring the maps was easy as we could use the same code from our previous US example.

CRUCIALLY: We also need to wrap each of our maps in seperate functions:

	(function() {
			*code goes here*
	})()

This helps keep any confusion with variable name conflicts in check.

Here is the Czech Republic, with regions in the tooltips:

But Germany is bigger ;-)