How to feel lucky on a Monday morning: calculating the travel distance between places and each point of the European population grid

Giorgio Comai — OBC Transeuropa

OBC Transeuropa
Nov 27, 2019 · 7 min read

Almost one million Romanian citizens cast their ballot for the second turn of the Romanian presidential elections in November 2019 from abroad, largely thanks to the fact that more than 800 polling stations around the world remained opened from Friday through Sunday over the election week-end. In some parts of Europe, polling stations were available not only in capital cities or major urban centers, but also in relatively remote locations.

Indeed, it took me about 25 minutes on a rainy Sunday to drive my wife to a polling station from the small village in the Italian Alps where I live.

A polling station in Trentino, Italy

Looking at the density of polling stations in Italy on a map, I had the feeling that I was not exceptionally lucky, and that indeed many Romanian voters in Italy had a polling station within relatively easy reach. Or… was I? How far was the average Italian resident from a Romanian polling station on 24 November 2019? I decided to find out.

Finding the distance between residents and polling stations

How far is the average Italian resident from a polling station for Romania’s presidential elections? To answer this question, first we need to know where polling stations are located, second we need to know where Italian residents actually live, and then, well, calculate the distance.

Here is our data on a map, Romanian polling stations on top of Italy’s population grid:

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.

Notes

European Data Journalism Network

Data-driven news on European issues, by a consortium of…

OBC Transeuropa

Written by

Osservatorio Balcani e Caucaso is a think tank focused on South-East Europe, Turkey and the Caucasus, based in Italy

European Data Journalism Network

Data-driven news on European issues, by a consortium of media from all over Europe

More From Medium

More on Data Journalism from European Data Journalism Network

More on Data Journalism from European Data Journalism Network

Glocal climate change

More on Data Journalism from European Data Journalism Network

More on Data Journalism from European Data Journalism Network

More on Data Journalism from European Data Journalism Network

More Than Boring Numbers: Data Journalism on Social Media

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade