query-684f675943104ac3a5f17a9c5007e8b7

rq turtle/ttl

Query items to the nearest items of another instance. (Q28564)public library to the nearest (Q294297)public bookcase it is possible to get a list of the 45 MIN and GROUP BY. With (Q40)Austria in (Q28564)public library and calculate the distance to a (Q40)Austria in (Q294297)public bookcase I made a query about all

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX geof: <http://www.opengis.net/def/geosparql/function/>

SELECT ?bookcaseLabel ?location1  (MIN(?distance) AS ?dist) WHERE {

?bookcase wdt:P31 wd:Q294297.
?bookcase wdt:P625 ?location1.
?bookcase wdt:P17 wd:Q40.
{

SELECT ?bib  ?location2   WHERE {
?bib wdt:P31 wd:Q28564.
?bib wdt:P625 ?location2.
?bib wdt:P17 wd:Q40.
}
}
BIND(geof:distance(?location1, ?location2) AS ?distance).
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }

}
GROUP BY ?bookcaseLabel ?location1
ORDER BY ?distance

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?bib") v2("?bookcase") v6("?dist") v6("?distance"):::projected v3("?location1"):::projected v5("?location2") c8(["bd:serviceParam"]):::iri c6(["wd:Q28564"]):::iri c5(["wd:Q40"]):::iri c10(["en"]):::literal c2(["wd:Q294297"]):::iri v2 --"wdt:P31"--> c2 v2 --"wdt:P625"--> v3 v2 --"wdt:P17"--> c5 v4 --"wdt:P31"--> c6 v4 --"wdt:P625"--> v5 v4 --"wdt:P17"--> c5 bind0[/"http://www.opengis.net/def/geosparql/function/distance(?location1,?location2)"/] v3 --o bind0 v5 --o bind0 bind0 --as--o v6 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c10 end bind2[/"min(?distance)"/] v6 --o bind2 bind2 --as--o v6