How to feel lucky on a Monday morning: calculating the travel distance between places and each point of the European population grid
By: Obc Transeuropa
Tags: Romania, Explainer, Elections, Maps, Data Journalism

Now that we have the data, the answer to my question is “simple”: let’s measure the distance between each population grid cell and each polling station in Italy to find out which is the closest. Then it will be possible to calculate the mean (or median) distance, weighting for the number of residents living in each square kilometer that composes the grid.

There are 172,216 one-km cells in the Italian population grid, and, making no other assumption, we’ll check which is the closest polling station to each of them.

This a computing-intensive process (it took approximately 6 hours on my laptop), but hey, this is what computer were made for. So a few hours later, here is our long-coveted answer: on average, an Italian resident lives less than 18 km from a Romanian polling station.[note 1] Fifty per cent of Italians live less than 13km from a Romanian polling station.[2]

To summarise again how we reached this number: Eurostat publishes a population grid that tells how many people live in each square km of the continent. After having calculated the distance between the centre of each of these squares and the location of a Romanian polling station in Italy, we calculated a weighted mean value, “weighted” according to the number of people living in each square km, so that places with many residents in cities “weigh” more than places with few residents in the countryside.

But… but… do you think people fly to polling stations?

Yes, dear reader, you are right. I just calculated the distance “as the crow flies”. Mind you, I believe this information is very telling and impressive, as residents of most countries would likely need to drive hundreds of kilometers to reach a polling station if they are abroad on election day. But as you will surely remember from the beginning of this story, this author lives in the Alps, where mountains can, and indeed do, stand in the way between an Italian resident and their preferred Romanian polling station. Even worse, the wise Alpine resident knows from experience that what looks closest on a map does not necessarily mean easiest to reach.

Let’s take it from the start looking at my native Trentino-Alto Adige/South Tyrol: population grid and Romanian polling stations.

Even if the map does not show the mountains, it is easy to guess from the population grid that they are there.

Let’s move on to a specific example. Let’s say that somebody in Vigo Cavedine, where part of my family hails from, wants to know how far they are from a Romanian polling station. They would soon find out that, as the crow flies, the closest polling station is in Rovereto, and is just 11 km from where they are.

The good folks of Vigo Cavedine are however not so easily misled by all of these data. They know that Trento is actually easier to reach.[3]

And they are right:

Indeed, it takes about 10 minutes less to reach the polling station North of Trento than the one in Rovereto; by road, it’s also about 7 km closer.

Now, if we had to answer this question only for the good folks of Vigo Cavine, then we could just use Google Maps, or ask around, for that matter. The problem is that we want to find this figure for all 172,216 one-km cells of the Italian population grid. Since we cannot take for granted that “the closest” is also “the easiest to reach”, it means that we should make more than one query for each grid cell. Even if we check, say, for the 5 closest polling stations, that makes 861,080 queries. The lovely folks at Google charge 5 US dollars for each 1000 requests, which means… let me add up the numbers… 4,305 USD.

Not bad. But perhaps a bit on the expensive side of things for a rainy Sunday afternoon curiosity?

OpenStreetMap, which is reasonably complete in terms of road connections in Italy, comes to the rescue. Unfortunately, there’s no OpenStreetMap service that will let me make hundreds of thousands of queries for free, but hey, it’s open. I installed on my own laptop OSRM, the OpenStreetMap routing machine, downloaded the data for Italy (thanks OpenStreetMap contributors!), prepared them for routing, and… off we go.[4]

Since at this stage I had a routing engine on my laptop, and I could torture it as much as I liked, I did not even limit the number of polling stations to check, and had it calculate the distance between each grid cell and each polling station. Yes, that’s more than twenty million queries (distance and time are two separate queries)… just because I can, and because I don’t have to hand over to Google 116,246 dollars for the pleasure.

OSRM is really fast, and on my cheap laptop it crunched all of the above in about 15 hours.

On a glorious Monday morning…

…I could wake up and feel that I was lucky. Even, better, I knew I was lucky.

On average, Italians would need to drive about 40 minutes to reach a Romanian polling station. Half of Italians could reach one in less than 35 minutes. But it took me only 25: I am officially lucky.