Geocode to Commons Category

Convert latitude/longitude to a Wikidata item and Wikimedia Commons category.

Interactive map ↗ — click any location to geocode it.

How it works
1
Find OSM polygons
Query PostGIS for all polygons that contain the given point.
2
Sort by admin level
Order polygons by admin_level descending — most specific first.
3
Check wikidata tag
For each polygon, look for a wikidata tag and resolve the Commons category.
4
Check ref:gss tag
If no wikidata tag, try ref:gss and look up the matching Wikidata item via WDQS.
5
Match by name
Try finding a nearby Wikidata item with the same name using WDQS.
6
Return result
Return the most specific Wikidata QID and Commons category found.
API

GET /?lat=<lat>&lon=<lon>

Returns JSON with the Wikidata item and Commons category for the given coordinates.

Parameter Values Description
lat decimal degrees Latitude
lon decimal degrees Longitude
needs_commons true (default)
false
When true, only returns a result if a Wikimedia Commons category can be found. When false, returns the best matching Wikidata item even if it has no Commons category — matched by OSM relation or way ID via the Wikidata Query Service.
Example response
{
  "wikidata": "Q184618",
  "commons_cat": {
    "title": "County Tipperary",
    "url": "https://commons.wikimedia.org/wiki/Category:County_Tipperary"
  },
  "admin_level": 6,
  "coords": { "lat": 52.41037, "lon": -7.84651 }
}
Examples
Place Coordinates Links
Adur 50.8326, -0.2689 detail API
Babcary 51.05, -2.598 detail API
Berwick St James 51.158, -1.906 detail API
Brackenborough with Little Grimsby 53.392, -0.022 detail API
Buckland, Hertfordshire 51.9687, -0.0327 detail API
Camberwell and Peckham 51.486, -0.089 detail API
Corby 52.4914, -0.69645 detail API
Danehill 51.059, 0.05 detail API
Dartford 51.473, 0.221 detail API
East Kilbride 55.7644, -4.177 detail API
Ebbesbourne Wake 51.034, -2.005 detail API
Ely 52.387, 0.294 detail API
England 52.9469, 0.1324 detail API
Fernhurst 51.07, -0.718 detail API
Fleet Marston 51.8532, -0.8829 detail API
Fulstow 53.463, -0.027 detail API
Halton 53.351, -2.701 detail API
Harlow 51.779, 0.128 detail API
Hartington Town Quarter 53.154, -1.8034 detail API
Haugham 53.322, 0.032 detail API
Hollingbury Castle 50.8553, -0.1192 detail API
Hotwells, Bristol 51.452, -2.621 detail API
Lambourn 51.51, -1.547 detail API
London Borough of Hounslow 51.4785, -0.354 detail API
Minstead 50.9, -1.6 detail API
Newton St Petrock 50.893, -4.265 detail API
Papworth Everard 52.253, -0.122 detail API
Sheffield 53.309, -1.539 detail API
Shenstone 52.62, -1.884 detail API
South Kilworth 52.43, -1.11 detail API
Stoke-on-Trent 52.9953, -2.1768 detail API
Tattershall Thorpe 53.117, -0.202 detail API
Terrington St Clement 52.766, 0.31 detail API
Upton Snodsbury 52.18, -2.08 detail API
Warkton 52.421, -0.651 detail API
West Lindsey 53.498, -0.415 detail API
Weston-on-the-Green 51.867, -1.204 detail API
Wildmore 53.059, -0.144 detail API
Windsor 51.4564, -0.6486 detail API
Zeals 51.0804, -2.3263 detail API

Source code: https://git.4angle.com/edward/geocode