Where's your local?
Sometimes you’ve gotta go where everybody knows your name.
There are a lot of pubs in Ireland, and as it happens if you go to the Revenue.ie you can get a list of all of them. On that site you’ll find a CSV file containing every currently licensed premises in the country, as well as their owners and addresses. There are $14,200$ premises listed in that file, which is a lot, but this includes all off-licenses, hotel bars, and restaurants that sell alcohol. We can strip out all of those leaving us only with the pubs proper, there are only $6,778$ of those, which equates to around about one pub for every 500 adults in the country. Not far off enough for everyone to be able to go to the pub at once I’d say.
The breakdown of pubs by county looks like this,
which looks to me like it’s some kind of function of area and population size.
In order to work out where your local is we need to get the exact location of each of these pubs. We have the addresses, we just need to turn those into latitudes and longitudes, a process called geo-coding. Thankfully Google Maps provides an API to do this, it’s just a matter of writing a small script to iterate over the addresses in that file and ask Google about each one. Since this data in the Revenue file is entered by hand there’s a lot of heterogeneity in the addresses, some are formatted weirdly, misspelled, or refer to local place-names that Google can’t find. To control for this I’ve filtered out all of the pubs that don’t have a trading name, since Google seems to really struggle with finding these. It’s a bit of a shame to have to drop these since there are quite a few and they mostly seem to be rural pubs, but since they don’t have names or specific street addresses Google’s just not going to be able to find them. A further caveat is that there’s no guarantee that when Google does find a pub it’s the right one. I’ve spot checked the results here and there, but unfortunately I don’t personally know all of the six thousand-odd pubs in the country so I can’t be sure that it’s worked in every case. My guess is that it’s probably right more than $95\%$ of the time, but that’s based on a fairly small set of checks.
Now that we have the locations of all of the pubs we can make a map,
It’s really cool that you can so clearly see the outline of the country just by looking at the pubs.
What we want is to split up the country so that for every point we know where the nearest pub is. Thankfully this is fairly easy to do, the mathematical object that we want is called a Voronoi Diagram, which, given a set of special points, splits up a region into patches where each patch is the set of points closer to one special point than to any other.
Making that Voronoi Diagram we get a map like this,
Now we can easily see what the local is for any point in Ireland, no more wondering. One nice this is that we can also zoom out and see which Irish pub is closest to any point in the world.1 For instance it looks like if you live in the US then the closest Irish pub to you is the Fisherman’s Bar in Portmagee, Co. Kerry.
There’s a lot of fun to be had playing around with this map, and I imagine it could come in handy in some kind of pint emergency.
-
For the purposes of this map I’ve used a flat Voronoi Diagram, which is inaccurate for spherical objects like the surface of the Earth. At the scale of Ireland this shouldn’t cause a problem, but the cells won’t be accurate as we zoom out to large scales. Making proper spherical Voronoi Diagrams is non-obvious, but there is a Python implementation that will take care of it for you. Watch this PyCon talk for more details. ↩