Wikidata:OpenStreetMap

From Wikidata
Jump to: navigation, search

This page is about Wikidata's collaboration with OpenStreetMap (Q936) (OSM). We particularly welcome OSM contributors who are new to Wikidata!

New to Wikidata?[edit]

Welcome! We recommend you read our general introduction, first.

Coordinates in Wikidata[edit]

We add coordinates to items in Wikidata using coordinate location (P625). See, for example Birmingham Town Hall (Q2191338).

Note that due to copyright issues it is not possible to import coordinates from OpenStreetMap to Wikidata. It also applies to importing coordinates from Wikipedia that were added there based on OpenStreeMap data. See https://www.wikidata.org/w/index.php?title=Wikidata:Project_chat&oldid=553348860#Importing_locations_from_OpenStreetMap for more details.

Linking from Wikidata to OSM[edit]

Because OSM IDs are not stable, and based on suggestions from the OSM community, we do not recommend adding a property for OSM IDs to Wikidata. Instead, work from the coordinates, and look for a similar item (instance of (P31) = bridge (Q12280), for example).

Linking from OSM to Wikidata[edit]

See the Wikidata key on the OSM wiki. For example, the OSM object https://www.openstreetmap.org/way/37716925 is tagged wikidata=Q2191338 - meaning Birmingham Town Hall (Q2191338).

It is also possible to use well-established wikipedia key to link to Wikidata via Wikipedia article.

User script[edit]

The user script "Overpass" adds a map showing a feature tagged in OpenStreetMap with the ID of that item, if any. It allows checking the tagging in OSM, and finding items which are not tagged in OSM, but probably should be.

Tool matching wikidata and OSM objects[edit]

https://osm.wikidata.link/ detects possible matches and allows quickly adding them to OSM

Combined database with both Wikidata and OSM data[edit]

Wikidata+OSM SPARQL query service combines both databases, and allows querying them using the same tool as Wikidata Query Service itself.

Linking from Wikipedia to OSM, using Wikidata identifiers[edit]

After adding wikidata tags to OSM objects, how to find them once again? The answer is Overpass. It's a tool to query OSM data. Overpass Turbo shows the results nicely on a zoomable map. Writing queries for it, is a bit tricky though. That's where this module comes in:

OSM Lua Module (Please click through to see the documentation)

With a minimum of parameters, it allows to generate queries related to the article it's invoked from.

Query[edit]

Here is an example of two queries to list the department of France (Q6465), their ISO 3166-2 code (P300), Wikidata ID and OSM ID :

from the Wikidata side (with Wikidata Query) from the OSM side (with overpass turbo) link
#French départements with Name, Wikidata ID, OSM relation ID, and ISO 3166-2 code
SELECT ?itemLabel ?item ?OSM ?code
WHERE
{
	?item wdt:P31 wd:Q6465 . #French départements
	?item wdt:P300 ?code . #with ISO 3166-2 code
	OPTIONAL { ?item wdt:P402 ?OSM }. #OSM relation if avalaible
	SERVICE wikibase:label { bd:serviceParam wikibase:language "fr" }
}
Try it!
/* French départements with Name, Wikidata ID, OSM relation ID, and ISO 3166-2 code */
[out:csv("name","wikidata",::id,"ISO3166-2")];
(
  relation["admin_level"="6"]["wikidata"]["ISO3166-2"~"^FR-..$"];
);
out tags;

Further information[edit]