Geocode coordinates to Commons Category
- Overpass query to find OSM polygon that contain given lat/lon.
- Sort list of OSM polygons by admin_level descending.
- Check each polygon for wikidata tag, starting with highest admin_level first.
- If the wikidata tag isn't found try looking for a 'ref:gss' tag and look for matching Wikidata item using the
Wikidata Query service (WDQS)
- Finally try match by name. Look for nearby items with the same name using WDQS.
- Return the most specific Wikidata QID and Commons Category.
Examples
{% for lat, lon, name in samples %}
- {{ name }} ({{ lat }}, {{ lon }})
—
API call
{% endfor %}
source code: https://github.com/EdwardBetts/uk-geocode