query-41d5c86b3321eb2720c171de1f842f35
Map of things in Oxford colour-coded by type
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 rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:Map{"hide": ["?location"]}
SELECT ?place ?placeLabel (SAMPLE(?loc) AS ?location) ?layer WHERE {
?place wdt:P131 wd:Q34217;
wdt:P31 ?type.
MINUS { ?place wdt:P576 [] } # Not closed down
OPTIONAL { ?place wdt:P625 ?coords }
OPTIONAL { ?place p:P159/pq:P625 ?hqcoords }
BIND (IF (BOUND(?coords), ?coords, ?hqcoords) AS ?loc)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". ?type rdfs:label ?layer.?place rdfs:label ?placeLabel }
} GROUP BY ?place ?placeLabel ?layer
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?coords")
v4("?hqcoords")
v6("?layer"):::projected
v5("?loc"):::projected
v8("?location")
v1("?place"):::projected
v7("?placeLabel"):::projected
v2("?type")
a1((" "))
a2((" "))
c9(["bd:serviceParam"]):::iri
c2(["wd:Q34217"]):::iri
c11(["#91;AUTO_LANGUAGE#93;,mul,en"]):::literal
v1 --"p:direct/P131"--> c2
v1 --"p:direct/P31"--> v2
subgraph minus0["MINUS"]
style minus0 stroke-width:6px,fill:pink,stroke:red;
v1 --"p:direct/P576"--> a1
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v1 -."p:direct/P625".-> v3
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v1 -."p:P159".-> a2
a2 --"p:qualifier/P625"--> v4
end
bind1[/"if(bound(?coords),?coords,?hqcoords)"/]
v3 --o bind1
v4 --o bind1
bind1 --as--o v5
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c9 --"wikibase:language"--> c11
v2 --"rdfs:label"--> v6
v1 --"rdfs:label"--> v7
end
bind3[/"sample(?loc)"/]
v5 --o bind3
bind3 --as--o v8