Tutorial: Using Wikimapia data in QGIS
Wikimapia is a participatory mapping online project launched in 2006 by two Russian computer scientists, based on satellite imagery from Google. The operation is relatively simple: it is to trace places compared to satellite images and then assign annotations to explain what it is: a park, a hospital, a school, a mountain, etc. In 2013, more than 20 million locations were identified throughout the world.
Since 2010, data from Wikimapia is available under Creative Commons License Attribution-ShareAlike (CC BY-SA). However, given that the premises are drawn from the Google imagery, data from Wikimapia can be considered as “derivative work” which may ask questions of reuse, especially for commercial use. More information about the license: http://en.wikipedia.org/wiki/WikiMapia#Licensing
Like OpenStreetMap, Wikimapia is supported by the work of volunteer contributors. The generated data can be extremely accurate, particularly for cities, and sometimes more than OpenStreetMap as shown in the following example:
To view the map Wikimapia data, please visit the site: http://wikimapia.org/
However, despite the huge volume of information that sometimes has nothing to envy to OpenStreetMap or other databases, Wikimapia suffers from some flaws that severely limit its potential:
- The data is often in the local language which requires a systematic translation.
- The attribute data system is much less extensive and effective than tags in OpenStreetMap.
- Export of data is much more complex than for OpenStreetMap, which is well equipped (Geofabrik, HOT Exports …).
The purpose of this tutorial is to show you one way (among others) to export the data of Wikimapia, and create a layer for each type of object (e.g. a hospital layer, a layer of schools, etc.) to use in your QGIS project.
Downloading data through Wikimapia API
The API (Application Programming Interface) of Wikimapia is an interface that allows downloading the data contained in the Wikimapia database. This interface is accessible via the following link: http://wikimapia.org/api
Using the API is relatively complicated, we have simplified it for this tutorial into an Excel spreadsheet that can be downloaded here: Wikimapia_API_Builder
The Builder API is configured to download all items within a category contained in a specific area. You only have to change the values of orange cells:
- Key: in the orange cell in front of Key, enter your API key. If you do not have one, leave example (export will still work but you will not be able to download excessive amounts of data). To generate a key, go here: http://wikimapia.org/api?action=create_key
- Category ID: in this cell, you must enter the ID of the category you want to download (e.g. 287 for hospitals). To know the ID of the different categories, click See category full list.
- Bbox: within 4 Bbox cells (Boundary Box), enter the limits of the area you want to export. To find the limits, you can use the OSM export tool: www.openstreetmap.org/export
Be careful not to choose too large of an area, it is only possible to download 100 objects at a time. If you want to cover a large area, divide it into multiple queries.
Once you have filled the settings, copy the link in blue (right click on cell A20 -> Copy) and paste it into the address bar of your browser, which will effectively start downloading a .kml file which contains all the objects that match your query.
To verify that your export went well, you can open the downloaded .kml file in Google Earth:
Converting the kml in .shp
KML created by API Wikimapia is of “multigeometry” type which means that for the same purpose, there is both a point (placemark) and a line (you can see it very clearly in the Google Earth screenshot above, each school has both a yellow and a white outline placemark).
The problem is that QGIS does not know how to open this type of kml, so we will have to convert it into two separate files, splitting lines from points.
For this we will use the KML2KML software, downloadable here: kml2kml.geoblogspot.com/
Follow the standard installation procedure, and once installed, open KML2KML.
- Click on the folder icon at the top left to open the KML file that was created and uploaded by the Wikimapia API.
- Click the Export tab and choose “To Shapefile“
- Choose the path of shp output
KML2KML then creates 2 shapefiles, a polygon shapefile containing the centroids (marks) and another containing the polygon outline (lines).
You can open both shapefile in QGIS and thus add this additional source of data to your projects.
Bonus: if you want to get polygons from the lines shapefile, use the Lines to Polygons tool:
/!\ If you know a faster way to convert a shapefile to KML multigeometry (e.g. via a Python script), feel free to leave a comment 😉