Share this on Facebook
download .zip with all pictures
If you wanted to do this with software, you usually *write* a program. Writing software is not that hard.
The practice of manipulating such geospatial data is called [“geoprocessing”](https://en.wikipedia.org/wiki/Geoprocessing), and the general field is called [GIS](https://en.wikipedia.org/wiki/Geographic_information_system). A site that has questions and answers about GIS is the [GIS stack exchange](https://gis.stackexchange.com/). (I found out about the stuff on this paragraph by doing Google searches, I never wrote a software to do geoprocessing myself)
An easy programming language is called Python. [This question](https://gis.stackexchange.com/questions/91742/looking-for-python-module-to-do-lat-lon-calculations) on the GIS stack exchange asks how to do some simple geoprocessing task with Python. Some dude or dudette recommended the use of [GDAL](https://pypi.python.org/pypi/GDAL/) (this was also found through a Google search. I never used GDAL).
Well, suppose you (or someone reading this) bothered to tinker with this stuff, and installed Python, GDAL, and learned a bit of Python and so on.
To perform the task of the OP, we need learn how to calculate the *distance between two countries*. This is probably a very simple GIS query. Once we know how retrieve such distance, we can enumerate all pairs of European countries, and calculate the distance between them, discarding the countries further apart than 100 miles (that’s because if two countries are, say, 150 miles from each other, it’s impossible to be in one of them and be 100 miles apart of someone in the other country). This “brute force” approach isn’t very efficient if there is a lot of countries, but I think that Europe doesn’t have too many countries. Also, if we calculate the distance from the UK to Germany, we don’t need to calculate the distance from Germany to UK.
Then, we need to learn how to calculate whether a country border another. Well, that’s quite obvious, but it’s nice to have this check in the program too. Then we also discard those countries (we can’t be “two countries away” if your country borders mine).
We’re left with countries in Europe that aren’t more than 100 miles apart and don’t border each other. The problem is: some of them might be three countries away, not two. We could signal them in the map so that we can manually pick which countries are true candidates for the meme, but we are perfectionist: we want our GIS software to also decide this.
Here is an approach: we need to learn to calculate the *shorted straight line that connects two countries*. The result is where this line starts and ends. This seems tricky, but it’s as easy as calculating the distance of the previous task (it just tell you the endpoints instead of just saying the distance). Then, we draw then in a map for all countries found in the previous case, just for having a map like the OP.
We can look at those lines and see whether they cross more than one country (this means that, in order to go from country A to country B, you need to pass through two countries). But we can also learn how to *calculate which countries a given segment pass through*: if it’s more than one, we know it passes through two countries.
Another approach: we know country A doesn’t border country B. But does any of the countries that borders A, also border B? If yes, they are two countries apart. (that’s probably easier and more correct than the previous method)
So we’re left with some tasks to learn. We might read a book on GIS, or we might search internet about those tasks. We can, for example, ask in the GIS stack exchange how to perform those tasks with GDAL and Python. Perhaps someone else already asked, and we can use Google to find this.
The insanely cool thing about this is that someone with literally zero programming experience can download Python and start with the easier aspects of this, and slowly gain experience and learn how to do those tasks.
For someone with programming experience (but zero experience with GIS) this might be a weekend task. Or, more commonly, this might be a programming assignment in an university course about this subject. But for someone experienced with some GIS package, this might take some hours or minutes (depending on whether the person already knew how to perform some of those tasks).