query-39c0f35dffa102f1e676db487a67ceb2

rq turtle/ttl

Query to list districts of Russia, by federal subject (here, 'region', and whether they have pictures or not 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:Q2753 AS ?region) . # Limits results to Ryazan Oblast (Q2753) # 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 OPTIONAL { ?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
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:Q2753 AS ?region) .       # Limits results to Ryazan Oblast (Q2753)
      # 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
      OPTIONAL {
         ?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