query-2fcd15e1a54704cdce9de9271e665a21
Country distance vis-à-vis Monaco
SELECT ?place ?placeLabel ?location ?iso2 ?iso2Label ?iso3 ?iso3Label ?distance WHERE {
wd:Q235 wdt:P625 ?monaco. # coordinates of Monaco
?place wdt:P31/wdt:P279* wd:Q6256;
wdt:P625 ?location.
BIND(geof:distance(?location, ?monaco) as ?distance).
OPTIONAL{?place wdt:P297 ?iso2.}
OPTIONAL{?place wdt:P298 ?iso3.}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
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 geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#Country distance vis-à-vis Monaco
SELECT ?place ?placeLabel ?location ?iso2 ?iso2Label ?iso3 ?iso3Label ?distance WHERE {
wd:Q235 wdt:P625 ?monaco. # coordinates of Monaco
?place wdt:P31/wdt:P279* wd:Q6256;
wdt:P625 ?location.
BIND(geof:distance(?location, ?monaco) as ?distance).
OPTIONAL{?place wdt:P297 ?iso2.}
OPTIONAL{?place wdt:P298 ?iso3.}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?distance"):::projected
v5("?iso2"):::projected
v6("?iso3"):::projected
v3("?location"):::projected
v1("?monaco")
v2("?place"):::projected
a1((" "))
c1(["wd:Q235"]):::iri
c9(["bd:serviceParam"]):::iri
c11(["en"]):::literal
c5(["wd:Q6256"]):::iri
c1 --"wdt:P625"--> v1
v2 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c5
v2 --"wdt:P625"--> v3
bind0[/"http://www.opengis.net/def/function/geosparql/distance(?location,?monaco)"/]
v3 --o bind0
v1 --o bind0
bind0 --as--o v4
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P297".-> v5
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P298".-> v6
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c9 --"wikibase:language"--> c11
end