Goal: Fetch data from Open Street Map by using either Wikidata QIDs or Wikidata’s Wikidata Property „OpenStreetMap tag or key“ using Overpass Turbo.
Find one QID in OSM
Find the Bavarian parliament (link):
[out:json][timeout:25];
// gather results
(
nwr["wikidata"="Q266759"]({{bbox}});
);
// print results
out geom;
Find multiple QIDs in OSM
The syntax needs a little tweak to get more then one building: add a ~
and separate the QIDs with a pipe|
.
Find Bavarian parliament and the one in Lower Saxony (link):
[out:json][timeout:2500];
(
nwr[wikidata~"^(Q3987|Q161156)$"];
);
out geom;
Find multiple QIDs that share Wikidata properties
Unfortunately, the meta data, e.g. which buildings are parliaments, are way better in Wikidata than in Open Street Map. So, I look up all parliament buildings in Wikidata and copy-paste the QIDs in the Overpass Turbo Query.
SELECT ?qid
WHERE {
?item wdt:P31/wdt:P279* wd:Q7138926 ;
wdt:P17 wd:Q183
BIND(REPLACE(STR(?item), "http://www.wikidata.org/entity/", "") AS ?qid) .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
(Of course, a script can help, see this gist here)
[out:json][timeout:2500];
(
nwr[wikidata~"^(Q3987|Q161156|Q198106|Q266759|Q450982|Q527260|Q530788|Q568911|Q573656|Q772327|Q1474638|Q1618988|Q1802238|Q1803999|Q26869698|Q30528597|Q30530246|Q64513147|Q98645221|Q105501557|Q111719341)$"];
);
out geom;
Where to go: Federated Query
Actually, this is quite a hack – copy-pasting ids, omg.
Querying OSM and Wikidata can be just another usecase for federated queries and can be done with the SPARQL-Endpoint of Open Street Map, Documentation. But I have not tried it yet.
Ein Kommentar