query-ad78e94c215fbae1890ef0deaa1c36e6
How to add page ID for the wikipedia articles in given SPARQL queryHello. I really need help! Following query will list all tourist attractions around the given coordinates. It also shows the url of the wikipedia article for the items in the result set. But I really also need the page ID for every wikipedia article. With page ID I mean the numeric ID which is unique for every article in every wikipedia. Who has a clue? Thanks!
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?item ?itemLabel ?image ?itemCoordinates ?description ?wikipediaLink ?wikipediaID WHERE {
SERVICE wikibase:around {
?item wdt:P625 ?itemCoordinates .
bd:serviceParam wikibase:center "Point(8.2478 49.9929)"^^geo:wktLiteral .
bd:serviceParam wikibase:radius "5" .
}
FILTER (
EXISTS { ?item wdt:P31/wdt:P279* wd:Q570116 } # Tourist attractions
)
OPTIONAL { ?item wdt:P18 ?image }
OPTIONAL {
?item schema:description ?description .
FILTER(LANG(?description) = "de")
}
OPTIONAL {
?wikipediaLink schema:about ?item ;
schema:isPartOf <https://de.wikipedia.org/> .
}
FILTER EXISTS {
?wikipediaLink schema:about ?item ;
schema:isPartOf <https://de.wikipedia.org/> .
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "de". }
}
LIMIT 100
OFFSET 0
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?description"):::projected
v5("?image"):::projected
v2("?item"):::projected
v4("?itemCoordinates"):::projected
v1("?wikipediaLink"):::projected
a1((" "))
c3([https://de.wikipedia.org/]):::iri
c4(["de"]):::literal
c7(["wd:Q570116"]):::iri
c10(["bd:serviceParam"]):::iri
c14(["5"]):::literal
c12([sPoint(8.2478 49.9929)^^<http://www.opengis.net/ont/geosparql#wktLiteral>"]):::literal
f0[[" "]]
subgraph f0e0["Exists Clause"]
e0v1 --"schema:about"--> e0v2
e0v1 --"schema:isPartOf"--> e0c3
e0v2("?item"):::projected
e0v1("?wikipediaLink"):::projected
e0c3([https://de.wikipedia.org/]):::iri
end
f0--EXISTS--> f0e0
f0 --> v1
f0 --> c1
f0 --> v2
f0 --> c2
f0 --> c3
v1 --"schema:about"--> v2
v1 --"schema:isPartOf"--> c3
f1[[" "]]
subgraph f1e1["Exists Clause"]
e1v1 --"wdt:P31"--> e1a1
e1a1 --"wdt:P279"--> e1c3
e1v1("?item"):::projected
e1a1((" ")):::projected
e1c3(["wd:Q570116"]):::iri
end
f1--EXISTS--> f1e1
f1 --> v2
f1 --> c5
f1 --> a1
f1 --> c6
f1 --> c7
v2 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c7
subgraph s1["http://wikiba.se/ontology#around"]
style s1 stroke-width:4px;
v2 --"wdt:P625"--> v4
c10 --"wikibase:center"--> c12
c10 --"wikibase:radius"--> c14
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P18".-> v5
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v2 -."schema:description".-> v3
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v1 -."schema:about".-> v2
v1 --"schema:isPartOf"--> c3
end
subgraph s2["http://wikiba.se/ontology#label"]
style s2 stroke-width:4px;
c10 --"wikibase:language"--> c4
end