Skip to main content
Open Innovations is winding down and will no longer be commencing new work from May 2026.

All the atms, post offices, and pubs in the UK

For our constituency site I wanted to show the numbers of ATMs, pubs, and post offices in each UK Parliamentary constituency. To do that you first need lists of where they all are. That's often the hardest part.

Getting all the ATMs

It turns out that LINK publish data on every ATM and cash-at-the-till location. That's 46,711 ATMs. But, even better, they also publish totals for each Parliamentary constituency! Amazing! Job done.

You can see the result on the ATMs hex map. The Cities of London and Westminster constituency has by far the most ATMs.

Getting all the post offices

I found a House of Commons Library briefing on post office branches. It mentions that they have a table with the number of post offices by constituency but that is it only available to parliamentary users due to restrictions from the Post Office. Were there alternatives?

The official Post Office website lists 11,003 post offices but they don't publish them as a dataset. It turns out a few companies are happy to sell you lists. One said it had 8,451 post offices for £25. Another claimed 11,765 post offices for $95. Could either be trusted? Perhaps I could create a dataset from Open Street Map data for the UK?

I downloaded the PBF file for the UK from GeoFabrik and used osmconvert to convert this into an o5m file:

osmconvert input.pbf -o=input.o5m

Next I could use osmfilter to pull out everything tagged amenity=post_office:

osmfilter input.o5m --keep="amenity=post_office" --drop-relations > post-offices.osm

I then used ogr2ogr along with an osmconf.ini file to extract each object type: "points", "lines", "multilinestrings", "multipolygons", and "other_relations":

ogr2ogr -overwrite --config OSM_CONFIG_FILE osmconf.ini -skipfailures -f GeoJSON post-offices-points.geojson post-offices.osm points 2>&1
ogr2ogr -overwrite --config OSM_CONFIG_FILE osmconf.ini -skipfailures -f GeoJSON post-offices-lines.geojson post-offices.osm lines 2>&1
ogr2ogr -overwrite --config OSM_CONFIG_FILE osmconf.ini -skipfailures -f GeoJSON post-offices-multilinestrings.geojson post-offices.osm multilinestrings 2>&1
ogr2ogr -overwrite --config OSM_CONFIG_FILE osmconf.ini -skipfailures -f GeoJSON post-offices-multipolygons.geojson post-offices.osm multipolygons 2>&1
ogr2ogr -overwrite --config OSM_CONFIG_FILE osmconf.ini -skipfailures -f GeoJSON post-offices-other_relations.geojson post-offices.osm other_relations 2>&1

This produces five GeoJSON files with all the UK's post offices. However, I realised that osmfilter had also allowed through some nodes/ways that weren't amenity=post_office. There were some bits of highways, random solar panels, and segments of political boundaries amongst others. That was very annoying. I had to write some code to go through them all and reject any that didn't have the correct property.

This gave me a GeoJSON with 9,294 results but these turned out to include entrance doors and other things that weren't actually post offices in-and-of-themselves.

At this point, Daniel on Mastodon told me about osmium. Osmium can process everything from the original PBF file much quicker than the multiple steps above and without all the big, intermediate, files. I installed it on WSL with:

sudo apt install osmium-tool

 I then just ran the commands:

osmium tags-filter -o postoffices.osm.pbf united-kingdom-latest.osm.pbf -R /amenity=post_office
osmium export postoffices.osm.pbf -o postoffices.geojson

Osmium quickly returned a lot more features than I got via osmconvert/osmfilter/ogr2ogr. However some of these are LineStrings which are also represented in MultiPolygons.

I got the constituency shapes from the ONS GeoPortal's Westminster Parliamentary Constituencies (July 2024) Boundaries UK BFE and then it was just a matter of maths/code to go through working out which constituency each was in. It turned out two weren't matched to constituencies and these were just over the Irish border. That suggests the GeoFabrik boundaries include a buffer zone which is probably sensible.

After ignoring features that didn't actually have the amenity=post_office tag, I'm left with 10,718 post offices.

You can see the result on the post offices hex map. As you can see, there are more post offices in the largest, rural, constituencies such as Argyll, Bute and South Lochaber. This shouldn't be entirely surprising given that the Post Office is required by government to meet six "access criteria".

Getting all the pubs

Now that I'd worked out how to get all the post offices it was just a matter of running the same code again to extract all the amenity=pub and amenity=bar from Open Street Map using osmium:

osmium tags-filter -o pubs.osm.pbf united-kingdom-latest.osm.pbf /amenity=pub,bar
osmium export pubs.osm.pbf -o pubs.geojson

When I tried to match the features to constituencies, around 20 failed to match. Eight were in Ireland. The rest seemed to be in the UK and had names like "Horatio's Bar", "The Lighthouse Champagne Bar", and "Oceans Bar". That nautical theme was a clue to why they hadn't matched; they were all at the ends of piers or harbour walls and so were just outside of the "full extent" boundaries from ONS.

I manually edited the boundary file to extend the relevant constituencies to include the piers. The end result is 69,254 pubs/bars.

You can see the result on the pubs hex map. The hotspots on this map mostly correspond to the hotspots on the ATMs hex map; places with pubs/bars often need ATMs nearby.

Any more for any more?

We've added ATMs, post offices, and pubs to our hex maps. Are there any other sorts of thing that would be good to extract from Open Street Map? If you have any good candidates, send us a suggestion.

Thanks to our sponsors, who enable us to work on mission-led projects like this.