query-3d4cd451bf32e51f60e60a7754e48c0f

rq turtle/ttl

Objekte in einem Bundsland (mit Unterabfrage)

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#Objekte in einem Bundsland (mit Unterabfrage)
#defaultView:Map,Table

select ?object ?objectLabel ?objectDescription ?coord ?image
where {
  ?object wdt:P131/wdt:P279* ?item.      
  ?object (wdt:P31/wdt:P279*) wd:Q33506 .  # ist ein Museum (oder Unterklasse)
  #?object (wdt:P31/wdt:P279*) wd:Q55488 .   # ist ein Bahnhof (oder Unterklasse) 
  #OPTIONAL { ?object wdt:P18 ?image . }     
  OPTIONAL { ?object wdt:P625 ?coord. }  

# hier kommt die Unterabfrage mit den Kreisen und Städten des Bundeslandes
{  
SELECT distinct ?item 
#?itemLabel ?itemDescription ?kreisschluessel 
       (SAMPLE(?coordinate) AS ?coord)              # nur eine Koordinate soll genutzt werden
WHERE {
  { ?item wdt:P31/wdt:P279* wd:Q106658.             # alle Landkreise (294 von 294)
    MINUS { ?item wdt:P576 _:b1. }                  # ohne Auflösungsdatum
  }
  union
  {  ?item p:P31 ?statement .
     ?statement ps:P31/wdt:P279* wd:Q22865 .        # alle Kreisfreie Städte in Deutschland  (107 von 107)
     MINUS { ?statement pq:P582 [] }                # ohne Auflösungsdatum
  }

  #OPTIONAL { ?item wdt:P440 ?kreisschluessel}       # Kreise mit Kreisschlüssel (399 von 401)
  MINUS { ?item wdt:P576 _:b2. }                    # ohne Auflösungsdatum   
  #OPTIONAL { ?item wdt:P625 ?coordinate. }          # Koordinate für Kartenansicht


  ?item wdt:P131 wd:Q1205.                           # liegt in Thüringen
  #?item wdt:P131 wd:Q1202.                           # liegt in Sachsen


}
GROUP BY ?item #?itemLabel ?itemDescription ?coord ?kreisschluessel
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "de,en,[AUTO_LANGUAGE]" }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?coord"):::projected v5("?coordinate") v2("?item") v1("?object"):::projected v4("?statement") a4((" ")) a6((" ")) a7((" ")) a1((" ")) a2((" ")) a3((" ")) a5((" ")) c6(["wd:Q106658"]):::iri c12(["wd:Q1205"]):::iri c4(["wd:Q33506"]):::iri c10(["wd:Q22865"]):::iri c14(["bd:serviceParam"]):::iri c16(["de,en,#91;AUTO_LANGUAGE#93;"]):::literal v1 --"p:direct/P131"--> a1 a1 --"p:direct/P279"--> v2 v1 --"p:direct/P31"--> a2 a2 --"p:direct/P279"--> c4 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P625".-> v6 end subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v2 --"p:P31"--> v4 v4 --"p:statement/P31"--> a5 a5 --"p:direct/P279"--> c10 subgraph minus0["MINUS"] style minus0 stroke-width:6px,fill:pink,stroke:red; v4 --"p:qualifier/P582"--> a6 end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v2 --"p:direct/P31"--> a3 a3 --"p:direct/P279"--> c6 subgraph minus1["MINUS"] style minus1 stroke-width:6px,fill:pink,stroke:red; v2 --"p:direct/P576"--> a4 end end union0r <== or ==> union0l end subgraph minus2["MINUS"] style minus2 stroke-width:6px,fill:pink,stroke:red; v2 --"p:direct/P576"--> a7 end v2 --"p:direct/P131"--> c12 bind4[/"sample(?coordinate)"/] v5 --o bind4 bind4 --as--o v6 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c14 --"wikibase:language"--> c16 end