I've written before about the wealth of free information that is Ordnance Survey OpenData. Recently I've been poking about with it some more, and I made the map below, showing railway lines, stations, motorways, cities and towns. I generated it using Python and Ordnance Survey's Meridian 2 data set, and their 1:50000 Scale Gazetteer, which lists place names and geographical features along with their location, type of feature (town, city, farm, etc) and other information.

Click for bigger. Railway lines are brown, stations are white dots, and motorways are blue. Small red dots represent towns, and large red dots represent cities. Source: OS OpenData 1:50000 Scale Gazetteer and Meridian 2. Contains Ordnance Survey data © Crown copyright and database right 2012.

When I generated the above map, it struck me as unusual that there was a city in the middle of nowhere up in Scotland, not connected with any railway line or motorway. Now, there are a few of these "joke cities" around, such as Ripon and Wells, that were granted city status centuries ago and haven't grown in population as much as other settlements. But I was curious about this one - I didn't know there were any examples in Scotland.

It turns out that the isolated red blob in Scotland represents the tiny village of St David's, about ten miles west of Perth. You may be surprised to discover that this unlikely-looking settlement is listed by Ordnance Survey as a city.

Now, the question "what is the smallest city in the United Kingdom" is a pub quiz favourite, and some of you may know that the answer is indeed St Davids, with a population of around 2,000. The problem is, the city of St Davids is in Wales.

So you've got the city called St Davids in Wales, and the little village called St David's in Scotland. According to their Gazetteer, Ordnance Survey has for the last 19 years bestowed city status upon the wrong one.

SEQ KM_REF NAME NORTH EAST CO_CODE COUNTY FULL_COUNTY F_CODE E_DATE UPDATE_CO
205716NN9420St David's720500294500PKPth & KinPerth and KinrossC01-MAR-1993I
205717SM7525St Davids / Tyddewi225500175500PBPembPembrokeshireO13-APR-2012U
The relevant entries in the Gazetteer, with some irrelevant fields removed. The field F_CODE (feature code) is the important one: C means city, and O means "other settlement". E_DATE shows when the record was last updated.

The Gazetteer is used by services that provide a search facility over place names in the UK. For example, the mistake appears on the Explore Britain website, which uses Ordnance Survey data. Compare the "OS Classification" fields in the entries for St David's, Perth and Kinross, Scotland and St Davids, Pembrokeshire, Wales.

I've informed Ordnance Survey of the problem. I expect they'll get back to me next week, but in the meantime, I encourage the dozen or so residents of St David's in Scotland to enjoy their city status and try to avoid the 2,000 disgruntled citizens of St Davids in Wales knocking on the door asking for their city back.