Video: the radical right & 4 critical elections in Western Europe in 2017

AfD results in 2017 federal election in Germany (map of districts)

As (West) European election years go, 2017 was quite something. The French party system changed beyond recognition. The radical right entered Germany’s national parliament for the first time. UKIP was wiped out, but May still managed to lose a comfortable majority. And very high fragmentation resulted in a coalition that looks improbable even by Dutch standards.

SCoRE is our multinational project that explores the link between local and regional living conditions on the one hand and radical right attitudes and behaviours in these four countries on the other. Sometimes, serendipity is really a thing. Because we had our individual-level data collection scheduled for this year anyway, we gained some unique insights into all four big Western European elections of 2017.

Accordingly, my colleagues have written up reports for France, Germany, the Netherlands, and the UK, complete with beautiful maps. Who does not like maps?

But perhaps you’re pressed for time or not sure if you really want to read four (fairly short) reports? With the European Parliamentary elections on the horizon, I made a short explainer/teaser video about them to bring you up to speed in just over two minutes. I have a hunch that afterwards, you will want to read all four pieces.

Free historical maps of Germany and Europe

It is mildly embarrassing to come across a great resource that is hosted within one’s own institution by accident (read: google). Unwittingly googling one’s own publications is definitively worse, but that is not the point. Nonetheless, I was happy to stumble upon the Institute of European History’s digital map server when I needed to illustrate my point about territorial cleavages in Germany. The site has a slightly dusty look and uses gifs for previews, but the licence is more than generous and the coverage and quality are impressive. If you ever need a map of Hessen-Kassel’s administrative structures in 1821, look no further. The only thing that is missing (as far as I can tell) are shapefiles, but if you are serious about GIS applications, you can convert/georeference the postscript files. For lecture slides, the gifs should suffice anyway.

Putting candidates in their place with R

I’m more and more intrigued by the potential spatial data hold for political science. Once you begin to think about it, concepts like proximity and clustering are basic building blocks  for explaining social phenomena. Even better, since the idea of open data has gone mainstream, more and more spatially referenced information becomes available, and when it comes to free, open source software, we are spoilt for choice or, at least in my case, up and beyond the point of utter confusion.

For our paper on the effect of spatial distance between candidates and their prospective voters,  we needed  a choropleth map of English Westminster constituencies that shows how many of the mainstream candidates live within the constituency’s boundaries. Basically, we had three options (not counting the rather few user-contributed packages for Stata): GRASS, a motley collection of Python packages, and a host of libraries for R.

GRASS is a full-blown open source GIS, whose user interface is perfect for keyboard aficionados and brings back happy memories of the 1980s. While GRASS can do amazing things with raster and vector maps, it is suboptimal for dealing with rectangular data. In the end, we used only its underrated cartographic module, which reliably creates high-resolution postscript maps.

Python has huge potential for social scientists, both in its own right and as a kind of glue that binds various programs together. In principle, a lot of GIS-related tasks could be done with Python alone. We used the very useful geopy toolboxfor converting UK postcodes to LatLong co-ordinates, with a few lines of code and a little help from Google.

Putting candidates in their place with R 5
Candidate locations by constituency

The real treasure trove, however, is R. The quality of packages for spatial analysis is amazing, and their scope is a little overwhelming. Applied Spatial Data Analysis with R by Roger Bivand, who wrote much of the relevant code, provides much-needed guidance.

Counting the number of mainstream candidates living in a constituency is a point-in-polygon problem: each candidate is a co-ordinate enclosed by a constituency boundary. Function overlay from package sp carries out the relevant operation. Once I had it located, I was seriously tempted to loop over constituencies and candidates. Just in time, I remembered the R mantra of vectorisation. Provided that points (candidates) and polygons (constituencies) have been transformed to the same projection, all that is needed is this:

mymap@data$homeconst1 <-overlay(candpos1,mymap)
mymap@data$homeconst2 <-overlay(candpos2,mymap)
mymap@data$homeconst3 <-overlay(candpos3,mymap)

This works because candpos1 is a vector of points that represent the spatial positions of all Labour candidates. These are tested against all constituency boundaries. The result is another vector of indices, i.e. sequence numbers of the constituencies the candidates are living in. Put differently, overlay takes a list of points and a bunch of polygons and returns a list that maps the former to the latter. With a bit of boolean logic, a vector of zeros (candidate outside constituency) and ones (candidate living in their constituency) ensues. Summing up the respective vectors for Labour, Tories, and LibDems then gives the required count that can be mapped. Result!

Putting candidates in their place with R 6