Downloading Ward Maps from OpenStreetMap using Overpass
You can download ward maps from OSM by following this
NOTE: While the following is technically the way to do it, ward level data is not very accurate in OSM at the time. Unless a local OSM contributor tells you that this data has been verified with the actuals from the local self-governing body, then do not rely on this. You can do the verification/edits yourself and download too.
OpenStreetMap (called OSM) is the map of the world powered by people like you and me. Go to openstreetmap.org to explore it or download an app powered by OSM data like osmand or maps.me from your app store.
People across the world have added administrative boundaries at various levels on to OSM. For consistency across India, this follows the following standard1:
admin_level | Boundary | |
---|---|---|
2 | Country | All countries are admin_level 2, including India |
4 | State | Kerala, Karnataka, etc |
5 | District | Kannur, Wayanad, etc |
6 | Taluk | |
8 | LSG | Municipality, Village, etc |
10 | Ward |
Since ward falls at admin_level=10, that’s the data that we need.
To be able to tell openstreetmap to give us this data, we can use an advanced API of OSM called Overpass API. To make queries to this API on the web, we can use Overpass turbo.
For this post, we will use overpass-turbo.eu.
Overpass
Turbo allows us to create Overpass API queries using a Wizard. By clicking on the Wizard button on the navbar, we can run the wizard. In the wizard, let us type a query that might work. For example, if I’m looking to download wards of Payyannur municipality, I might type in the wizard this: admin_level=10 in Payyannur
.
That gives me the following query:
/*
This has been generated by the overpass-turbo wizard.
The original search was:
“admin_level=10 in Payyannur”
*/
[out:json][timeout:25];
// fetch area “Payyannur” to search in
{{geocodeArea:Payyannur}}->.searchArea;
// gather results
(
// query part for: “admin_level=10”
node["admin_level"="10"](area.searchArea);
way["admin_level"="10"](area.searchArea);
relation["admin_level"="10"](area.searchArea);
);
// print results
out body;
>;
out skel qt;
It also loads the data in the map and allows us to visualize it. The zoom to data button on the left pane of the map allows us to go to the loaded map if we’re too far away in Europe or so.
By clicking “Data” on top right we can see the raw data that was fetched. In this case it is json format because that’s what the query generated. We can click the “Export” button and download this data in various formats including GeoJSON, KML, and as image.
In this case of Payyannur, though, we got more than what we actually wanted. All the wards in the Payyannur Taluk has been fetched. This includes wards from Payyannur municipality, but also wards from nearby villages like Eramam Kuttur. If you notice, there’s a {{geocodeArea:Payyannur}}
in the query. What this does is search another tool called Nominatim to find the actual object within OSM that corresponds to the name we gave (in this case, Payyannur). Most likely, in our case, Nominatim is returning the Payyannur Taluk and that’s why we got a larger area.
We can specify Payyannur Municipality in another way here to avoid this confusion. What we will do is use the wikidata QID of Payyannur Municipality which is Q16137435. We can replace this line:
{{geocodeArea:Payyannur}}->.searchArea;
with this line:
( area["wikidata"="Q16137435"];) ->.searchArea;
And that’ll give us the exact data we need.
To share this with friends, you can click “Share” and get a link like this one: http://overpass-turbo.eu/s/1Ab8