query-91d2b5fa1f1b3e49ed9cacf204a1877f

rq turtle/ttl

Dataset of cities of Ukraine, suitable for import in GIS software

Author: [[User:Valerio Bozzolan]]

Date: 2023-10-05

License: CC0

SELECT DISTINCT ?city ?cityLabel ?cityLocation ?administrative ?administrativeLabel ?country WHERE {

# Force to Ukraine # (Explicit here so you can easily do the same for other countries) BIND(wd:Q212 AS ?country)

?city wdt:P31/wdt:P279* wd:Q515. ?city wdt:P17 ?country . ?city wdt:P625 ?cityLocation . ?city wdt:P17 ?country. ?city wdt:P131 ?administrative. ?administrative p:P31 ?administrativeInstanceOf;

# Exclude former cities. MINUS { ?city wdt:P31/wdt:P279* wd:Q22674925. }

# Excludes administratives with end time MINUS { ?administrativeInstanceOf pq:P582 ?administrativeEndTime. }

# Exclude administratives that are abolished. MINUS { ?administrative wdt:P576 ?administrativeAbolishedDate. }

SERVICE wikibase:label { bd:serviceParam wikibase:language "uk,en" . } } ORDER BY DESC(?administrativeLabel) DESC(?cityLabel)

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 p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# Dataset of cities of Ukraine, suitable for import in GIS software
# Author: [[User:Valerio Bozzolan]]
# Date: 2023-10-05
# License: CC0
SELECT DISTINCT ?city ?cityLabel ?cityLocation ?administrative  ?administrativeLabel ?country WHERE {

  # Force to Ukraine
  # (Explicit here so you can easily do the same for other countries)
  BIND(wd:Q212 AS ?country)

  ?city wdt:P31/wdt:P279* wd:Q515.
  ?city wdt:P17 ?country .
  ?city wdt:P625 ?cityLocation .
  ?city wdt:P17 ?country.
  ?city wdt:P131 ?administrative.
  ?administrative p:P31 ?administrativeInstanceOf;

  # Exclude former cities.
  MINUS {
     ?city wdt:P31/wdt:P279* wd:Q22674925. 
  }

  # Excludes administratives with end time
  MINUS {
    ?administrativeInstanceOf pq:P582 ?administrativeEndTime.
  }

  # Exclude administratives that are abolished.
  MINUS {
    ?administrative wdt:P576 ?administrativeAbolishedDate. 
  }

  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "uk,en" .
  }
}
ORDER BY DESC(?administrativeLabel) DESC(?cityLabel)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?administrative"):::projected v9("?administrativeAbolishedDate") v8("?administrativeEndTime") v7("?administrativeInstanceOf") v1("?administrativeLabel"):::projected v4("?city"):::projected v2("?cityLabel"):::projected v5("?cityLocation"):::projected v3("?country"):::projected a1((" ")) a2((" ")) c8(["wd:Q22674925"]):::iri c12(["bd:serviceParam"]):::iri c3(["wd:Q515"]):::iri c14(["uk,en"]):::literal bind0[/"'wd:Q212'"/] bind0 --as--o v3 v4 --"p:direct/P31"--> a1 a1 --"p:direct/P279"--> c3 v4 --"p:direct/P17"--> v3 v4 --"p:direct/P625"--> v5 v4 --"p:direct/P17"--> v3 v4 --"p:direct/P131"--> v6 v6 --"p:P31"--> v7 subgraph minus1["MINUS"] style minus1 stroke-width:6px,fill:pink,stroke:red; v4 --"p:direct/P31"--> a2 a2 --"p:direct/P279"--> c8 end subgraph minus2["MINUS"] style minus2 stroke-width:6px,fill:pink,stroke:red; v7 --"p:qualifier/P582"--> v8 end subgraph minus3["MINUS"] style minus3 stroke-width:6px,fill:pink,stroke:red; v6 --"p:direct/P576"--> v9 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c12 --"wikibase:language"--> c14 end