query-c6d539444317a483779adb877954f149
TODO
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 ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?coord1 ?coord2 ?distance ?rank1 ?rank2 WHERE {
{
SELECT DISTINCT ?item ?coord1 ?coord2 ?rank1 ?rank2 WHERE {
?item wdt:P17 wd:Q35 . # in Denmark
?item wdt:P31/wdt:P279* wd:Q486972 . # settlement
?item p:P625 ?stat1 . ?stat1 ps:P625 ?coord1 . ?stat1 wikibase:rank ?rank1 .
?item p:P625 ?stat2 . ?stat2 ps:P625 ?coord2 . ?stat2 wikibase:rank ?rank2 .
filter ( str(?stat1) < str(?stat2) ) . # not the same
filter ( str(?rank1) = str(?rank2) ) . # are the same
}
} BIND(geof:distance(?coord1, ?coord2) as ?distance)
SERVICE wikibase:label { bd:serviceParam wikibase:language "da,en,[AUTO_LANGUAGE]". }
}
ORDER BY ?itemLabel
Query found at
- https://www.wikidata.org/wiki/User:Hjart/SPARQL_queries
- https://www.wikidata.org/wiki/Wikidata:Request_a_query/Archive/2019/10
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v7("?coord1"):::projected
v8("?coord2"):::projected
v9("?distance"):::projected
v6("?item"):::projected
v1("?itemLabel"):::projected
v2("?rank1"):::projected
v3("?rank2"):::projected
v4("?stat1")
v5("?stat2")
a1((" "))
c5(["wd:Q486972"]):::iri
c10(["bd:serviceParam"]):::iri
c12(["da,en,#91;AUTO_LANGUAGE#93;"]):::literal
c2(["wd:Q35"]):::iri
f0[["str(?rank1) = str(?rank2)"]]
f0 --> v2
f0 --> v3
f1[["str(?stat1) < str(?stat2)"]]
f1 --> v4
f1 --> v5
v6 --"p:direct/P17"--> c2
v6 --"p:direct/P31"--> a1
a1 --"p:direct/P279"--> c5
v6 --"p:P625"--> v4
v4 --"p:statement/P625"--> v7
v4 --"wikibase:rank"--> v2
v6 --"p:P625"--> v5
v5 --"p:statement/P625"--> v8
v5 --"wikibase:rank"--> v3
bind2[/"http://www.opengis.net/def/function/geosparql/distance(?coord1,?coord2)"/]
v7 --o bind2
v8 --o bind2
bind2 --as--o v9
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c10 --"wikibase:language"--> c12
end