query-514f4304448c7e26df0fee06fef99c12
Propertiescoordinate location (P625)instance of (P31)located in the administrative territorial entity (P131)
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 geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT
?place
?placeLabel
?dist
(GROUP_CONCAT(DISTINCT ?instanceLabel; SEPARATOR = ", ") AS ?instanceLabels)
(GROUP_CONCAT(DISTINCT ?adminLabel; SEPARATOR = ", ") AS ?adminLabels)
WHERE
{
wd:Q116716361 wdt:P625 ?loc .
SERVICE wikibase:around {
?place wdt:P625 ?location .
bd:serviceParam wikibase:center ?loc .
bd:serviceParam wikibase:radius "6" .
}
OPTIONAL { ?place wdt:P31 ?instance }
OPTIONAL { ?place wdt:P131 ?admin }
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
?instance rdfs:label ?instanceLabel .
?place rdfs:label ?placeLabel .
?admin rdfs:label ?adminLabel .
}
BIND(geof:distance(?loc, ?location) as ?dist)
}
GROUP BY ?place ?placeLabel ?dist
ORDER BY ?dist
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?admin")
v9("?adminLabel"):::projected
v11("?adminLabels")
v10("?dist"):::projected
v5("?instance")
v7("?instanceLabel"):::projected
v10("?instanceLabels")
v2("?loc")
v4("?location")
v3("?place"):::projected
v8("?placeLabel"):::projected
c12(["en"]):::literal
c4(["bd:serviceParam"]):::iri
c7(["6"]):::literal
c1(["wd:Q116716361"]):::iri
c1 --"wdt:P625"--> v2
subgraph s1["http://wikiba.se/ontology#around"]
style s1 stroke-width:4px;
v3 --"wdt:P625"--> v4
c4 --"wikibase:center"--> v2
c4 --"wikibase:radius"--> c7
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v3 -."wdt:P31".-> v5
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v3 -."wdt:P131".-> v6
end
subgraph s2["http://wikiba.se/ontology#label"]
style s2 stroke-width:4px;
c4 --"wikibase:language"--> c12
v5 --"rdfs:label"--> v7
v3 --"rdfs:label"--> v8
v6 --"rdfs:label"--> v9
end
bind0[/"http://www.opengis.net/def/function/geosparql/distance(?loc,?location)"/]
v2 --o bind0
v4 --o bind0
bind0 --as--o v10
bind3[/"?instanceLabel"/]
v7 --o bind3
bind3 --as--o v10
bind4[/"?adminLabel"/]
v9 --o bind4
bind4 --as--o v11