query-1286793887f79759eeafe8f5274e498a
Ten nearest places to a place
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 DISTINCT (SUBSTR(STR(?place),32) as ?link) ?placeLabel
WHERE {
wd:Q1191 wdt:P625 ?loc2. #Starting point
{ SELECT DISTINCT ?place ?coords WHERE 
 {?item wdt:P195 wd:Q636400;
    wdt:P973 ?url FILTER (STRSTARTS(STR(?url),"http://jameelcentre") ).
VALUES ?property {wd:P180 wd:P1071}
?property wikibase:directClaim ?prop.
?item ?prop ?place.
?place wdt:P625 ?coords
 } }
BIND(geof:distance(?coords, ?loc2) AS ?distNum).
SERVICE wikibase:label {bd:serviceParam wikibase:language "en". 
?place rdfs:label ?placeLabel}
} ORDER BY ?distNum OFFSET 1 LIMIT 10
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v8("?coords")
  v9("?distNum")
  v4("?item")
  v10("?link")
  v2("?loc2")
  v7("?place"):::projected 
  v9("?placeLabel"):::projected 
  v6("?prop")
  v5("?property")
  v3("?url")
  c1(["wd:Q1191"]):::iri 
  c9(["bd:serviceParam"]):::iri 
  c5(["wd:Q636400"]):::iri 
  c11(["en"]):::literal 
  c1 --"wdt:P625"-->  v2
  f0[["starts-with(str(?url),'http://jameelcentre')"]]
  f0 --> v3
  v4 --"wdt:P195"-->  c5
  v4 --"wdt:P973"-->  v3
  bind1[/VALUES ?property/]
  bind1-->v5
  bind10(["wd:P180"])
  bind10 --> bind1
  bind11(["wd:P1071"])
  bind11 --> bind1
  v5 --"wikibase:directClaim"-->  v6
  v4 -->v6--> v7
  v7 --"wdt:P625"-->  v8
  bind2[/"http://www.opengis.net/def/function/geosparql/distance(?coords,?loc2)"/]
  v8 --o bind2
  v2 --o bind2
  bind2 --as--o v9
  subgraph s1["http://wikiba.se/ontology#label"]
    style s1 stroke-width:4px;
    c9 --"wikibase:language"-->  c11
    v7 --"rdfs:label"-->  v9
  end
  bind3[/"substring(str(?place),'32^^xsd:integer')"/]
  v7 --o bind3
  bind3 --as--o v10