query-3f7d678d99d425c93093f31caa092597

rq turtle/ttl

: I could not make a make query to get all German settlements in one query. But I made this query to select 50 of 419 German hasc values, and give all settlements with these values. You can run the query 9 times, increasing the OFFSET value in the subquery to get hasc values by 50 each time to get all. Stefan Kühn@ 09:04, 12 August 2022 (UTC)) talk (sk: I create a new version of your query. Now I filter only for Germany-HASC and also filter "instance_of" by a list of useful attributes. The result are over 75000 Items. I only need the label and the HASC. --Dipsacus fullonum @

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?itemLabel ?hasc
WHERE
{

{
  # Subquery to get all values of hasc in Germany  
  SELECT ?region ?hasc
  WHERE
  {
    ?region wdt:P8119 ?hasc .
    FILTER(REGEX(STR(?hasc), "^DE.[A-Z]{2}.[A-Z]{2}$","i")) 
    ?region wdt:P17 wd:Q183 . # country is Germany
  }
  #ORDER BY ?hasc
  #OFFSET 0
  #LIMIT 50
}  ?item wdt:P131 * ?region .
  #?item wdt:P31 / wdt:P279 * wd:Q486972 . # ?item is a subclass of human settlement
  VALUES ?instance_of { 
    wd:Q253019      # Ortsteil
    wd:Q486972      # Siedlung
    wd:Q262166      # Gemeinde in Deutschland
    wd:Q123705      # Stadtviertel
  } 
  ?item wdt:P31 ?instance_of .  
  #hint:Prior hint:gearing "forward" . 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,de". }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?hasc"):::projected v4("?instance_of") v3("?item") v2("?region") c9(["bd:serviceParam"]):::iri c5(["wd:Q183"]):::iri c11(["#91;AUTO_LANGUAGE#93;,en,de"]):::literal f0[["regex(str(?hasc),'^DE.#91;A-Z#93;{2}.#91;A-Z#93;{2}$','i')"]] f0 --> v1 v2 --"wdt:P8119"--> v1 v2 --"wdt:P17"--> c5 v3 --"wdt:P131"--> v2 bind1[/VALUES ?instance_of/] bind1-->v4 bind10(["wd:Q253019"]) bind10 --> bind1 bind11(["wd:Q486972"]) bind11 --> bind1 bind12(["wd:Q262166"]) bind12 --> bind1 bind13(["wd:Q123705"]) bind13 --> bind1 v3 --"wdt:P31"--> v4 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c9 --"wikibase:language"--> c11 end