Distance to the Nearest Pub

Making silly maps is my jam, but I definitely have a strong US bias. I’m American, so the first thing that comes to mind is… America. It felt like time I made a map for some other country.

The obvious candidate was the British Isles, and what could be more British than pubs? I decided to find how far you’ll need to walk from any point on the Isles to get to the nearest pub.

This turned out to be the most expensive project I’ve ever worked on. I forgot I had already hit my Google Maps free API call limit, and ran up a $170 bill 😬.  Don’t be like me! Set your usage caps! But I’ll provide all the data below so you don’t need to repeat my mistake.

 

Gathering Data

First, I needed to get a list of all pubs in the British Isles. This was surprisingly easy to accomplish, but it did take a few steps to gather the data.

  1. I got UK pub data from the Food Hygiene ratings API. The Trafford Data Lab was particularly helpful here, providing ready-made R code to retrieve and format data from the API. The UK groups “pubs, bars, and nightclubs” into one category. Not all of these may be traditional pubs, but I took the dataset as-is.
  2. Ireland data came from 2018-2019 liquor license renewals. I did have to geocode it all, as it doesn’t come with coordinates. Google was unable to geocode some of the pubs exactly–it tended to place the pubs at the center of their towns. I declared that to be OK.
  3. Isle of Man data I got from the Google Places API
  4. Scotland seemed really bare in places, so I ran a second scrub with Google Places. It turns out a lot of pubs in Highlands also operate as hotels, and are coded as such in the UK Food Safety data. To determine if an establishment was truly a pub or just a hotel bar, I read TripAdvisor reviews–if a real live Brit described the place as a pub, that was good enough for me.

The code for all this is on Github, and the data I collected is available here.

 

Finding Distances

Then, to create my final map, I used the following method:

  1. Create a uniform grid of points to cover the British Isles. I went for a relatively coarse mesh (every .0625 latitude; .125 longitude) due to API costs.
  2. For each point, find the 5 closest pubs as the crow flies.
  3. Run these through Google maps to find the walking distance from the point to each pub. Why walking distance? Well, for one, we’re responsible pub-goers and don’t drive drunk. Also, the grid of points rarely falls on a road, which trips Google up if you ask for driving distance.
  4. Save the shortest walking distance for each point.
  5. Double check the top 500 longest distances. I found that the coast of Scotland was often picking up pubs in Northern Ireland, which led to insanely long walks. For this step, I reviewed the top 15 pubs, limited just to those on the same island as the point of interest.
  6. Save the overall shortest walking distance found for each point.
  7. Plot a Voronoi diagram to illustrate how long a walk you have from each point to a pub

The code–for getting distances as well as creating the plots below–is on Github. If you don’t have $170+ to blow on Google API calls, I also saved the final distances here.

Final Results

And the final result is below. Of course, this should be taken lightheartedly. Is 56.625, -4.625 really the farthest point from a pub? Probably not–there’s plenty of isolated islands that are technically infinitely far from a pub, unless you can walk on water–but it does show how pub-less northern Scotland is.

distance

 

And the same map, just with distances as the crow flies. I like how you can see the lonely pubs in the Highlands as pale circles in a light blue sea:

crowfinal

 

Conclusion

Though I’m still irritated with myself for making such a dumb mistake and not monitoring my API usage more carefully, I am pretty excited about the results! I’m impressed at how many pubs our neighbors across the pond have managed to cram into so little space. There’s no gaping blank spots like we have in many maps of the American Midwest, and working with a new geometry was lightly refreshing.

Stay tuned for roundabouts next!

2 comments

  1. An invaluable resource for natives and visitors alike! I mean that – brilliant. Britain is of course the home of the pub. And consider that pubs – as opposed to hotels or mere bars – are, sadly, declining in number…

    Like

  2. This is great, but it would have been much more interesting with a three-colour grading scheme. I’d have liked the palette to go from white to blue in the first ten miles, which is the most interesting data, then blue to yellow over the next twenty miles, and finally yellow to red for the final twenty miles.

    If nothing else, it would make the map much more colourful! But it would also show much more data visually rather than the huge amounts of white-or-slightly-blue areas.

    Great work, however!

    Like

Leave a Reply to bitaboutbritain Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s