query-8332204b813c99604129064d4ea6a264

rq turtle/ttl

Propertieslocated in the administrative territorial entity (P131)contains the administrative territorial entity (P150)applies to jurisdiction (P1001)instance of (P31)category's main topic (P301)category combines topics (P971)

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?item ?itemLabel WHERE {
  ## only upward relation P131 which might miss items if the P131-tree is incomplete
  ?territory (wdt:P131)* wd:Q5907 .
  ## alternative: also use downward relation P150 which might lead to unwanted items from former adminstrative relations
  # ?adminTree (wdt:P131)* wd:Q5907 .
  # ?adminTree (wdt:P150)* ?territory .
  ##
  {  
    ?item wdt:P131 ?territory # anything located in 
  } UNION { 
    ?item wdt:P1001 ?territory # or within territorial jurisdiction
  } UNION {
    ?item wdt:P31 wd:Q4167836 . # categories
    {
      ?item wdt:P301 ?territory # with topic
    } UNION {
      ?item wdt:P971 ?territory # or combining topic with something
    }
  } UNION {
    ?item wdt:P31 wd:Q13406463 . #lists
    ?item ?p ?statement .
    ?statement pq:P131 ?territory # with statements having qualifiers located in 
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "de" }
} ORDER BY ( ?itemLabel )

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?item"):::projected v1("?itemLabel"):::projected v4("?p") v5("?statement") v2("?territory") c13(["de"]):::literal c2(["wd:Q5907"]):::iri c8(["wd:Q13406463"]):::iri c11(["bd:serviceParam"]):::iri c5(["wd:Q4167836"]):::iri v2 --"wdt:P131"--> c2 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; subgraph union2[" Union "] subgraph union2l[" "] style union2l fill:#abf,stroke-dasharray: 3 3; v3 --"wdt:P31"--> c8 v3 -->v4--> v5 v5 --"pq:P131"--> v2 end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; v3 --"wdt:P31"--> c5 subgraph union3[" Union "] subgraph union3l[" "] style union3l fill:#abf,stroke-dasharray: 3 3; v3 --"wdt:P971"--> v2 end subgraph union3r[" "] style union3r fill:#abf,stroke-dasharray: 3 3; v3 --"wdt:P301"--> v2 end union3r <== or ==> union3l end end union2r <== or ==> union2l end end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v3 --"wdt:P1001"--> v2 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v3 --"wdt:P131"--> v2 end union0r <== or ==> union0l end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c11 --"wikibase:language"--> c13 end