query-a5e6572a30be1546504c5011233cdf49

rq turtle/ttl

Query to list districts of Russia, by federal subject (here, 'region', and whether they have pictures or not

Test: Must have a Wikipedia article

PREFIX schema: http://schema.org/ # remember to add this SELECT DISTINCT ?region ?regionLabel ?dist ?distLabel ?wplink ?pic # ?coord WHERE { ?dist wdt:P31 wd:Q2198484 . # district - is a - Russian district ?region wdt:P131 wd:Q159 . # region - is in administrative district of - Russia ?dist wdt:P131 ?region . # district - is located in the administrative territory of - a region #BIND (wd:Q1749 AS ?region) . # <------ CHANGE THIS TO SEE A DIFFERENT OBLAST/KRAI/etc. # OPTIONAL {?dist wdt:P625 ?coord } # district - has geographic coordinates of - ?coord (if added column for items that exist) #OPTIONAL {?dist wdt:P18 ?pic } . # add a column for pics (p18) if there is one in WD (toggle w/next line) MINUS {?dist wdt:P18 ?pic} . # use this instead of previous line to see items with NO PIC { ?wplink schema:about ?dist . # WP link - is about - ?dist ?wplink schema:inLanguage "en" . ?wplink schema:isPartOf https://en.wikipedia.org/ . } SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } } ORDER BY ASC(?regionLabel) ?distLabel

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#>
#Query to list districts of Russia, by federal subject (here, 'region', and whether they have pictures or not
#Test: Must have a Wikipedia article
PREFIX schema: <http://schema.org/> # remember to add this
SELECT DISTINCT ?region ?regionLabel ?dist ?distLabel ?wplink ?pic # ?coord 
WHERE {
      ?dist wdt:P31 wd:Q2198484 .         # district - is a - Russian district
      ?region wdt:P131 wd:Q159 .        # region - is in administrative district of - Russia
      ?dist wdt:P131 ?region .           # district - is located in the administrative territory of - a region
      #BIND (wd:Q1749 AS ?region) .       # <------ CHANGE THIS TO SEE A DIFFERENT OBLAST/KRAI/etc.
      # OPTIONAL {?dist wdt:P625 ?coord }   # district - has geographic coordinates of - ?coord (if added column for items that exist)
      #OPTIONAL {?dist wdt:P18 ?pic } .        # add a column for pics (p18) if there is one in WD   (toggle w/next line) 
      MINUS {?dist wdt:P18 ?pic} .           # use this instead of previous line to see items with NO PIC
      {
         ?wplink schema:about ?dist .   # WP link - is about - ?dist
         ?wplink schema:inLanguage "en" .
         ?wplink schema:isPartOf <https://en.wikipedia.org/> .
      }
      SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY ASC(?regionLabel) ?distLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?dist"):::projected v2("?distLabel"):::projected v5("?pic"):::projected v4("?region"):::projected v1("?regionLabel"):::projected v6("?wplink"):::projected c8(["en"]):::literal c2(["wd:Q2198484"]):::iri c4(["wd:Q159"]):::iri c10([https://en.wikipedia.org/]):::iri c12(["bd:serviceParam"]):::iri v3 --"wdt:P31"--> c2 v4 --"wdt:P131"--> c4 v3 --"wdt:P131"--> v4 subgraph minus0["MINUS"] style minus0 stroke-width:6px,fill:pink,stroke:red; v3 --"wdt:P18"--> v5 end v6 --"schema:about"--> v3 v6 --"schema:inLanguage"--> c8 v6 --"schema:isPartOf"--> c10 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c12 --"wikibase:language"--> c8 end