query-d7a2232af9c759309dacca7e09d1022b

rq turtle/ttl

.on TwitterOriginally posted

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
#defaultView:Map
SELECT ?item (SAMPLE(?title) AS ?itemLabel) (SAMPLE(?location) AS ?location) (SAMPLE(?language) AS ?layer) WHERE {
  VALUES ?wiki { <https://de.wikipedia.org/> <https://fr.wikipedia.org/> <https://it.wikipedia.org/> <https://rm.wikipedia.org/> }
  ?item wdt:P17 wd:Q39;
        wdt:P625 ?location.
  ?article a schema:Article;
           schema:about ?item;
           schema:isPartOf ?wiki;
           schema:inLanguage ?language;
           schema:name ?title.
  # filter out some stray results that have country Switzerland but coordinates outside it (e. g. rivers)
   {
  SELECT * WHERE {
    wd:Q39 p:P1332/psv:P1332/wikibase:geoLatitude ?n;
           p:P1333/psv:P1333/wikibase:geoLatitude ?s;
           p:P1334/psv:P1334/wikibase:geoLongitude ?e;
           p:P1335/psv:P1335/wikibase:geoLongitude ?w.
  }
}
  BIND(geof:latitude(?location) AS ?lat)
  BIND(geof:longitude(?location) AS ?lon)
  FILTER(?s <= ?lat && ?lat <= ?n &&
         ?w <= ?lon && ?lon <= ?e)
}
GROUP BY ?item
HAVING(COUNT(DISTINCT ?wiki) = 1)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v13("?_anon_42b5416610844a34809f33a099ae9de14247") v10("?article") v6("?e") v8("?item"):::projected v14("?itemLabel") v11("?language"):::projected v13("?lat") v15("?layer") v15("?location"):::projected v13("?lon") v3("?n") v1("?s") v12("?title"):::projected v4("?w") v7("?wiki") a2((" ")) a3((" ")) a4((" ")) a5((" ")) a6((" ")) a7((" ")) a8((" ")) a9((" ")) a1((" ")) c6(["schema:Article"]):::iri c3(["wd:Q39"]):::iri f0[[" = '1^^xsd:integer'"]] f0 --> a1 f1[["?s <= ?lat?lat <= ?n?w <= ?lon?lon <= ?e"]] f1 --> v1 f1 --> v13 f1 --> v3 f1 --> v4 f1 --> v13 f1 --> v6 bind2[/VALUES ?wiki/] bind2-->v7 bind20([https://de.wikipedia.org/]) bind20 --> bind2 bind21([https://fr.wikipedia.org/]) bind21 --> bind2 bind22([https://it.wikipedia.org/]) bind22 --> bind2 bind23([https://rm.wikipedia.org/]) bind23 --> bind2 v8 --"p:direct/P17"--> c3 v8 --"p:direct/P625"--> v15 v10 --"a"--> c6 v10 --"schema:about"--> v8 v10 --"schema:isPartOf"--> v7 v10 --"schema:inLanguage"--> v11 v10 --"schema:name"--> v12 c3 --"p:P1332"--> a2 a2 --"p:statement/value/P1332"--> a3 a3 --"wikibase:geoLatitude"--> v3 c3 --"p:P1333"--> a4 a4 --"p:statement/value/P1333"--> a5 a5 --"wikibase:geoLatitude"--> v1 c3 --"p:P1334"--> a6 a6 --"p:statement/value/P1334"--> a7 a7 --"wikibase:geoLongitude"--> v6 c3 --"p:P1335"--> a8 a8 --"p:statement/value/P1335"--> a9 a9 --"wikibase:geoLongitude"--> v4 bind3[/"http://www.opengis.net/def/function/geosparql/latitude(?location)"/] v15 --o bind3 bind3 --as--o v13 bind4[/"http://www.opengis.net/def/function/geosparql/longitude(?location)"/] v15 --o bind4 bind4 --as--o v13 bind9[/"count(?wiki)"/] v7 --o bind9 bind9 --as--o v13 bind10[/"sample(?title)"/] v12 --o bind10 bind10 --as--o v14 bind11[/"sample(?location)"/] v15 --o bind11 bind11 --as--o v15 bind12[/"sample(?language)"/] v11 --o bind12 bind12 --as--o v15