OpenStreetMap User's Diaries
Rearranging the world around Nominatim for fun and profit
♦
There are a number of ongoing discussions about the geocoder on osm.org (Nominatim) in the forum at the moment. These include spelling tolerance, how it might work with data that does not exist in OSM yet and what it actually returns.
Sometimes the results of the last of those can be a bit odd. Here for example is a post office not far from me. The returned data (“Stillingto

There are a number of ongoing discussions about the geocoder on osm.org (Nominatim) in the forum at the moment. These include spelling tolerance, how it might work with data that does not exist in OSM yet and what it actually returns.
Sometimes the results of the last of those can be a bit odd. Here for example is a post office not far from me. The returned data (“Stillington Post Office & Stores, Main Street, Stillington, York, North Yorkshire, York and North Yorkshire, England, YO61 1JS, United Kingdom”) has three things that could plausibly be a county in there - York itself, North Yorkshire, and York and North Yorkshire. In OSM these are respectively a nearby place=city
node, and encompassing admin_level=6
and admin_level=5
relations.
The problem here is, like in the case of the Northern Irish super-councils mentioned in the forum, the data returned by Nominatim does match administrative areas but doesn’t entirely match places that people associate themselves with. Actually, we have three different hierarchies here:
- Postal (street address, village, post town, postcode, as returned by the Royal Mail’s postcode checker).
- Administrative (street address, civil parish, unitary council, combined authority, country)
- Geographic (street address, “something that implies where in Yorkshire”, either “North Yorkshire” or “Yorkshire”, country)
All of these have problems. Depending on who you talk to postal addresses should or should not include the “post town” any more, and that is very often not the nearest town, in the same county, or even nearby. The administrative regions don’t map onto any human places at all, and several different geographic hierarchies are possible.
I decided to see whether it would be possible to make Nominatim return a hierarchy from one plausible geographic (as opposed to administrative) scheme - that based on traditional counties. The English examples of these are mostly in OSM. They’re even signed on the ground in some places, for example here and here. There’s a whole discussion to be had about (a) do they belong in OSM or OHM and (b) if the latter, who’s going to move the data and based on what source. The English “traditional counties” in OSM seem to be the immediately pre-1974 ones, but of course boundaries did change a great deal leading up to that point (for example, Crayke, not far from our example post office above, was in Durham until 1844).
It’s relatively straightforward to “download OSM data, perform a known set of changes on it, and then do something else with it”. The raster, vector and Garmin maps that I create do that already. The code to do the necessary changes to remove “admin without place” and add “pretend admin levels” for the places we want to use instead is fairly simple. The code to reload a Nominatim database based on a Geofabrik download area is also simple.
Here’s what the results look like on a test server:
https://h20.atownsend.org.uk/nominatim/search?q=53.8234,-1.1397
Bell Lane, Cawood, West Riding of Yorkshire, Yorkshire, England, YO8 3RA, United Kingdom
That’s correctly returned “West Riding of Yorkshire” (the historic division that Cawood was in) and “Yorkshire”.
https://h20.atownsend.org.uk/nominatim/search?q=53.2597,0.2012
Back Lane, Bilsby, Parts of Lindsey, Lincolnshire, England, LN13 9PT, United Kingdom"
Likewise, for somewhere in Lincolnshire.
https://h20.atownsend.org.uk/nominatim/search?q=54.3446,-7.6285
Westville Terrace, Tonystick, Enniskillen, County Fermanagh, Northern Ireland, BT74 6GG, United Kingdom
Likewise for somewhere in one of the six counties in Northern Ireland. The “super-council” here is “Fermanagh and Omagh District Council” and that isn’t returned.
Somewhere in London that was historically in Middlesex:
https://h20.atownsend.org.uk/nominatim/search?q=51.5183438,-0.0785237
Williams Ale & Cider House, 22-24, Artillery Lane, Devonshire Square, London Borough of Tower Hamlets, London, Middlesex, England, E1 7LS, United Kingdom
And somewhere in the “City of London”
https://h20.atownsend.org.uk/nominatim/search?q=51.51509,-0.09330
Commerzbank, 30, Gresham Street, Bank, City of London, Middlesex, England, EC2V 7PG, United Kingdom
Alas, there are problems where both older and newer parts of the address overlap. This address is in the historic county of Surrey, but that isn’t getting returned:
https://h20.atownsend.org.uk/nominatim/search?q=51.474537,-0.157530
142, Battersea Park Road, Falcon Estate, Clapham Junction, London Borough of Wandsworth, London, England, SW11 4LT, United Kingdom
And similarly in Barnoldswick (the source of the “B” in Rolls Royce aero engine names such as “RB211”), somewhere historically in the West Riding of Yorkshire
https://h20.atownsend.org.uk/nominatim/search?q=53.924692,%20-2.172959
Skipton Road, Barnoldswick, Earby, Borough of Pendle, Yorkshire, England, BB18 6HJ, United Kingdom
it would surely be possible, by special-casing a few more expressions in a few more areas, to work around these last two issues, but this isn’t a serious suggestion for “how a geocoder should be set up”, just a whimsical demonstration that it’s possible to achieve radically different results without understanding in any way how Nominatim does what it does, just installing it as per the instructions. A more sensible but less whimsical solution might be to use ceremonial counties, although currently in OSM there are some gaps.
I notice that there’s a session at SOTM EU in Dundee in November presented by the main developer of Nominatim “It’s traditional - Boundaries and Places in the UK” which sounds like it’s addressing exactly this sort of problem. Should be interesting…
(photo from Geograph, cc by SA)
♦
There are a number of ongoing discussions about the geocoder on osm.org (Nominatim) in the forum at the moment. These include spelling tolerance, how it might work with data that does not exist in OSM yet and what it actually returns.
Sometimes the results of the last of those can be a bit odd. Here for example is a post office not far from me. The returned data (“Stillingto
There are a number of ongoing discussions about the geocoder on osm.org (Nominatim) in the forum at the moment. These include spelling tolerance, how it might work with data that does not exist in OSM yet and what it actually returns.
Sometimes the results of the last of those can be a bit odd. Here for example is a post office not far from me. The returned data (“Stillington Post Office & Stores, Main Street, Stillington, York, North Yorkshire, York and North Yorkshire, England, YO61 1JS, United Kingdom”) has three things that could plausibly be a county in there - York itself, North Yorkshire, and York and North Yorkshire. In OSM these are respectively a nearby place=city
node, and encompassing admin_level=6
and admin_level=5
relations.
The problem here is, like in the case of the Northern Irish super-councils mentioned in the forum, the data returned by Nominatim does match administrative areas but doesn’t entirely match places that people associate themselves with. Actually, we have three different hierarchies here:
- Postal (street address, village, post town, postcode, as returned by the Royal Mail’s postcode checker).
- Administrative (street address, civil parish, unitary council, combined authority, country)
- Geographic (street address, “something that implies where in Yorkshire”, either “North Yorkshire” or “Yorkshire”, country)
All of these have problems. Depending on who you talk to postal addresses should or should not include the “post town” any more, and that is very often not the nearest town, in the same county, or even nearby. The administrative regions don’t map onto any human places at all, and several different geographic hierarchies are possible.
I decided to see whether it would be possible to make Nominatim return a hierarchy from one plausible geographic (as opposed to administrative) scheme - that based on traditional counties. The English examples of these are mostly in OSM. They’re even signed on the ground in some places, for example here and here. There’s a whole discussion to be had about (a) do they belong in OSM or OHM and (b) if the latter, who’s going to move the data and based on what source. The English “traditional counties” in OSM seem to be the immediately pre-1974 ones, but of course boundaries did change a great deal leading up to that point (for example, Crayke, not far from our example post office above, was in Durham until 1844).
It’s relatively straightforward to “download OSM data, perform a known set of changes on it, and then do something else with it”. The raster, vector and Garmin maps that I create do that already. The code to do the necessary changes to remove “admin without place” and add “pretend admin levels” for the places we want to use instead is fairly simple. The code to reload a Nominatim database based on a Geofabrik download area is also simple.
Here’s what the results look like on a test server:
https://h20.atownsend.org.uk/nominatim/search?q=53.8234,-1.1397
Bell Lane, Cawood, West Riding of Yorkshire, Yorkshire, England, YO8 3RA, United Kingdom
That’s correctly returned “West Riding of Yorkshire” (the historic division that Cawood was in) and “Yorkshire”.
https://h20.atownsend.org.uk/nominatim/search?q=53.2597,0.2012
Back Lane, Bilsby, Parts of Lindsey, Lincolnshire, England, LN13 9PT, United Kingdom"
Likewise, for somewhere in Lincolnshire.
https://h20.atownsend.org.uk/nominatim/search?q=54.3446,-7.6285
Westville Terrace, Tonystick, Enniskillen, County Fermanagh, Northern Ireland, BT74 6GG, United Kingdom
Likewise for somewhere in one of the six counties in Northern Ireland. The “super-council” here is “Fermanagh and Omagh District Council” and that isn’t returned.
Somewhere in London that was historically in Middlesex:
https://h20.atownsend.org.uk/nominatim/search?q=51.5183438,-0.0785237
Williams Ale & Cider House, 22-24, Artillery Lane, Devonshire Square, London Borough of Tower Hamlets, London, Middlesex, England, E1 7LS, United Kingdom
And somewhere in the “City of London”
https://h20.atownsend.org.uk/nominatim/search?q=51.51509,-0.09330
Commerzbank, 30, Gresham Street, Bank, City of London, Middlesex, England, EC2V 7PG, United Kingdom
Alas, there are problems where both older and newer parts of the address overlap. This address is in the historic county of Surrey, but that isn’t getting returned:
https://h20.atownsend.org.uk/nominatim/search?q=51.474537,-0.157530
142, Battersea Park Road, Falcon Estate, Clapham Junction, London Borough of Wandsworth, London, England, SW11 4LT, United Kingdom
And similarly in Barnoldswick (the source of the “B” in Rolls Royce aero engine names such as “RB211”), somewhere historically in the West Riding of Yorkshire
https://h20.atownsend.org.uk/nominatim/search?q=53.924692,%20-2.172959
Skipton Road, Barnoldswick, Earby, Borough of Pendle, Yorkshire, England, BB18 6HJ, United Kingdom
it would surely be possible, by special-casing a few more expressions in a few more areas, to work around these last two issues, but this isn’t a serious suggestion for “how a geocoder should be set up”, just a whimsical demonstration that it’s possible to achieve radically different results without understanding in any way how Nominatim does what it does, just installing it as per the instructions. A more sensible but less whimsical solution might be to use ceremonial counties, although currently in OSM there are some gaps.
I notice that there’s a session at SOTM EU in Dundee in November presented by the main developer of Nominatim “It’s traditional - Boundaries and Places in the UK” which sounds like it’s addressing exactly this sort of problem. Should be interesting…
(photo from Geograph, cc by SA)