User:Planemad/Kartographer maps workshop
Workshop to create maps with Kartographer at WikidataCon Berlin.
- Date: Sunday 29 October 2017
- Venue and Time: Room 'E' 12.30-13.30PM
Workshop
[edit]The goal of the workshop is to walthrough how Wikidata and OpenStreetMap data can be connected to easily create interactive maps on Mediawiki projects. The workshop makes use of the Extension:Kartographer which is available by default on the Wikivoyage project. The example may not working on other Wikimedia projects without the extension.
Wikimedia Maps
[edit]The Wikimedia Map service is the primary provider of open maps for Wikimedia Projects. The service consists of a zoomable street level map of the world generated using data from the OpenStreetMap Project.
OpenStreetMap
[edit]The OpenStreetMap Project is the largest source of crowdsourced geographical data. It takes a few minutes to sign up and improve the map of your home neighborhood using the online map editor called iD via the [edit] button. One can add or improve any type of map feature like roads, buildings, trees and even trash cans.
This make OSM the ideal database to store open map data. The data is licensed under the ODbL license which allows data reuse with attribution and share alike.
OSM Data structure
[edit]Every map feature is defined as shape (points, lines, areas) and some metadata (`key`=`value` pairs) called tags. This allows adding defining a full geographical feature like a street with its shape and properties like road type, width, multilingual and even a Wikidata reference.
It is also possible to group smaller shapes as a larger group with a different set of tags. This is called a relation and is commonly used for defining boundaries, highway routes and river systems.
- Use taginfo to find commonly used tags for the feature you want to map
Connecting OSM data and Wikidata
[edit]Adding Wikidata ids to OSM
[edit]Adding Wikidata tags to OSM map features helps link map features on the OSM database to their associated item on the Wikidata database. This allows:
- querying a map feature from OSM based on a Qid
- adding extra metadata form Wikidata to map features like language labels
See http://wiki.openstreetmap.org/wiki/Wikidata#Linking_from_OSM_to_Wikidata
Adding OSM ids to Wikidata
[edit]Adding OSM ids to Wikidata is not encouraged since the OSM ids can change as the shapes are merged or split often. Relation ids are more stable and can be added using Property:P402
See http://wiki.openstreetmap.org/wiki/Wikidata#Linking_from_Wikidata_to_OSM
Adding OSM tags to Wikidata
[edit]Tags on OSM help describe the various properties of map features. These tags can also be added to their corresponding Wikidata item using Property:P1282 . This allows:
Creating Wiki maps using OSM data
[edit]Now that we have updated map data on the OpenStreetMap Project with Wikidata links, it can be used to embed interactive maps on Mediawiki sites with a few lines of code. There are two ways to do this:
Kartographer Maps
[edit]The easiest way to create a map with a shape highlighted from OSM is to use the Kartographer extension. The extension helps to query a shape from OSM using a Qid or a SPARQL query
Usage
[edit]<mapframe> and <maplink>
[edit]A mapframe will create and embedded map while a maplink will open the map in a popup.
A maplink of Alaska using the shape from OSM linked to Qid=Q797
Type and service
[edit]You can set the data to overlay on the map using the `type` and `service` parameter.
- type:feature for directly defining geojson shape
- type: ExternalData to fetch the shape from an external source like OSM (service:geoshape or geoline) or commons (service:page)
Examples
[edit]QID to be updated:- http://overpass-turbo.eu/s/mRF
More examples
- https://en.wikipedia.org/wiki/User:Naveenpf/sandbox
- Constituencies for the election to the German Bundestag 2017, with winning candidate and party
How to
[edit]Generate GeoJSON from OSM
[edit]Using Overpass Turbo to query OSM for features with a certain tag or feature id and export to a GeoJSON.
- Lookup the feature with a certain wikidata id http://overpass-turbo.eu/s/sFh