query-965f79660891aebed4dd4f61ed1a45a5
joch - a mountain or a saddle?
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 ps: <http://www.wikidata.org/prop/statement/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:Map{"hide":"?rgb"}
#title: find geographical objects by regular expressions
SELECT ?item ?itemLabel ?itemDescription ?isALabel (GROUP_CONCAT(DISTINCT ?whereLabel; SEPARATOR=', ') AS ?whereLabels) (SAMPLE(?image) AS ?image) ?coord ?rgb ?layer WHERE {
{
SELECT DISTINCT ?item WHERE {
?item wdt:P17 wd:Q40 . # österreich
?item wdt:P31 [] . # with type
?item wdt:P625 [] . # with coords
# check name:
?item rdfs:label ?itemLabel .
FILTER (LANG(?itemLabel) = "de").
FILTER regex(?itemLabel, ".*joch$", "i").
# filter to objects assigned to (P131) administrative units in Austria
MINUS {?item wdt:P31 wd:Q261543 }.
Minus {?item wdt:P31 wd:Q406957 }.
?item wdt:P131 ?wo .
minus {?item wdt:P31 wd:Q667509 .} # no municipalities
minus {?item wdt:P31 wd:Q871419 .} # no districts
{?wo wdt:P31 wd:Q871419 .} union {?wo wdt:P31 wd:Q261543 .}
minus {?wo wdt:P31 wd:Q667509 .}
}
}.
?item wdt:P31/wdt:P279* ?isA.
VALUES ?isA {wd:Q8502 wd:Q16887036 wd:Q2231510 wd:Q10862618}. # filter for types
OPTIONAL {
?isA rdfs:label ?isALabel.
FILTER(LANG(?isALabel) = 'de') .
}
?item p:P625 ?coordStatement .
?coordStatement ps:P625 ?coord .
#MINUS { ?coordStatement prov:wasDerivedFrom/pr:P143 wd:Q169514 } # imported from Wikimedia project: Swedish Wikipedia
#MINUS { ?coordStatement prov:wasDerivedFrom/pr:P143 wd:Q837615 } # imported from Wikimedia project: Cebuano Wikipedia
#MINUS { ?coordStatement prov:wasDerivedFrom/pr:P248 wd:Q1194038 } # stated in: GEOnet Names Server
OPTIONAL {
?item wdt:P131 ?where .
OPTIONAL {
?where rdfs:label ?whereLiteral .
FILTER(LANG(?whereLiteral) = 'de') .
}
}
BIND(IF(BOUND(?where), IF(BOUND(?whereLiteral), ?whereLiteral, STRAFTER(STR(?where), 'entity/')), 'no P131') AS ?whereLabel) .
OPTIONAL { ?item wdt:P18 ?image }
BIND(IF(EXISTS { ?item p:P18 [] }, '0000ff', 'ff0000') AS ?rgb) .
BIND(IF(EXISTS { ?item p:P18 [] }, 'With image', 'Without image') AS ?layer) .
SERVICE wikibase:label { bd:serviceParam wikibase:language '[AUTO_LANGUAGE,de,en]' }
} GROUP BY ?item ?itemLabel ?itemDescription ?isALabel ?whereLabels ?coord ?rgb ?layer