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 =

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
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.
 * Wikimedia Maps: Browse
 * Improve the map data on OpenStreetMap: Map | Wiki

OpenStreetMap
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
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

Adding Wikidata ids to OSM
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
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
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:
 * querying wikidata items by OSM tags. Example: Items on Wikidata tagged with OSM tag for city

= Creating Wiki maps using OSM data =

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
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
==== and

Type and service
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)


 * Documentation: https://www.mediawiki.org/wiki/Help:Extension:Kartographer

Examples
QID to be updated:- http://overpass-turbo.eu/s/mRF

More examples


 * https://en.wikipedia.org/wiki/User:Naveenpf/sandbox

Generate GeoJSON from OSM
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

Resources

 * Overpass to query OSM https://overpass-turbo.eu/s/sFe
 * https://www.mediawiki.org/wiki/Help:Extension:Kartographer/OSM
 * https://www.wikidata.org/wiki/Template:Wikidata_list