Jorge López
Sep 8, 2018 · 3 min read

You’re always travelling! Anywhere you haven’t been to yet?

Fortunately yes, there’re still many places I haven’t visited. And I say fortunately because that means it makes sense to keep on travelling, which I love! Believe it or not, despite being European and travelling quite a lot (though not so much as people tend to think!), I haven’t even covered all Europe. Don’t envy me so much, folks ;-).

Actually, I’m going to show you which countries are missing. Fairly easy with python and geopandas. There is one dataset in geopandas which stores world’s countries, their shapes and locations, so let’s read it and concentrate on Europe:

Notice how I’m adding a column been_to to the dataframe, which stores yes or no depending on what I myself entered when being prompted (yes, this code is not robust to stupid or evil users, but I’m not stupid nor evil!). So now we just need to plot it:

The function above is just a wrapper for geopandas plot, which in turn invokes matplotlib plot behind the scenes. I’m telling it to color red countries I haven’t been to and blue those I’ve been to, which gives:

Oops, Russia and French Guiana mess things up…

Two things are happening here: first, Russia is too large (that’s why usually European maps are limited by the Urals), and secondly, France’s polygon also includes the French Guiana, which is too southern. So what now?

Well, geopandas isn’t just for plotting, but it also lets us play with geography and geometry. What I do in the code below is the following:

  1. Get all European countries except for France and Russia.
  2. Compute the envelope (i.e., the bounding box) of its union (that is, a polygon with all countries together).
  3. Select for all countries just the part inside this bounding box (this effectively crops Russia and France).
  4. Plot the result.

And we get the following:

Voilà! Red ones are waiting!

Much better, huh? So you can see that I’ve been to:

  • All Western Europe.
  • Nearly all Central Europe (except for Slovakia, Serbia, Kosovo, Albania and Macedonia).

Whereas there are regions I am still to discover:

  • Scandinavia (Norway, Sweden, Finland) and Iceland.
  • Most of Eastern Europe (Estonia, Latvia, Lithuania, Belarus, Ukraine and Moldova).
  • Russia.

So which of these do you think should be my next European trip? Suggestions welcome!

P.D.: all code is available in my Github account as a Jupyter notebook. If you’re a python user and have already installed all required dependencies (Anaconda strongly suggested!), feel free to download and run the code. Also, if you don’t want to mess with dependencies or you aren’t confident with python yet, upload the notebook (the .ipynb file) directly to Google Colab and run it. Works like a charm!

Jorge López

Written by

Senior Data & Machine Learning Scientist @ Instituto de Ingeniería del Conocimiento. Love to analyze data, to code, to travel and to write about all this.

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