query-12c4c11c321fcecdad966dcfb8838930

rq turtle/ttl

tuntematon 50-55% 55-60% 60-65% 65-70% 70-75% 75-100% Voting activity of muncipal elections of Finland 2012. example map. KartographerThis is a

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 
?city
?cityLabel
(?city as ?id) 
(SAMPLE(?img) as ?img) 
(SAMPLE(?fill) as ?fill) 
(concat('[[:d:',substr(str(?city),32,100),  ' | ', ?cityLabel, ']]') as ?title)
(concat('[[File:', substr(str(?img), 52, 100), '|200px]]') as ?description)
WHERE {
  ?item wdt:P361 wd:Q20252009.
  ?item wdt:P1867 ?total_voters .
  ?item wdt:P1697 ?active_voters.
  ?item wdt:P1001 ?city.
  BIND (100*?active_voters/?total_voters AS ?percent) .
  BIND(
    if(?percent>= 75, '#610604', 
    if(?percent>= 70, '#994910', 
    if(?percent>= 65, '#D0B01F', 
    if(?percent>= 60, '#CBF13F', 
    if(?percent>= 55, '#ABF97A', 
    if(?percent>= 50, '#B1FFB3', '#a6a6a6')))))
  ) as ?fill).
  OPTIONAL { ?city wdt:P94 ?img . }
  SERVICE wikibase:label { bd:serviceParam wikibase:language 'en,fi,sv'. }
} GROUP BY ?city ?cityLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?active_voters") v4("?city"):::projected v10("?description") v9("?fill"):::projected v8("?id") v9("?img"):::projected v1("?item") v5("?percent") v9("?title") v2("?total_voters") c8(["bd:serviceParam"]):::iri c2(["wd:Q20252009"]):::iri c10(["en,fi,sv"]):::literal v1 --"wdt:P361"--> c2 v1 --"wdt:P1867"--> v2 v1 --"wdt:P1697"--> v3 v1 --"wdt:P1001"--> v4 bind0[/"'100^^xsd:integer' * ?active_voters / ?total_voters"/] v3 --o bind0 v2 --o bind0 bind0 --as--o v5 bind1[/"if(?percent >= '75^^xsd:integer','#610604',if(?percent >= '70^^xsd:integer','#994910',if(?percent >= '65^^xsd:integer','#D0B01F',if(?percent >= '60^^xsd:integer','#CBF13F',if(?percent >= '55^^xsd:integer','#ABF97A',if(?percent >= '50^^xsd:integer','#B1FFB3','#a6a6a6'))))))"/] v5 --o bind1 bind1 --as--o v9 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v4 -."wdt:P94".-> v9 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c10 end bind4[/"?city"/] v4 --o bind4 bind4 --as--o v8 bind5[/"sample(?img)"/] v9 --o bind5 bind5 --as--o v9 bind6[/"sample(?fill)"/] v9 --o bind6 bind6 --as--o v9 bind7[/"concat('#91;#91;:d:',substring(str(?city),'32^^xsd:integer','100^^xsd:integer'),' | ',?cityLabel,'#93;#93;')"/] v4 --o bind7 null --o bind7 bind7 --as--o v9 bind8[/"concat('#91;#91;File:',substring(str(?img),'52^^xsd:integer','100^^xsd:integer'),'|200px#93;#93;')"/] v9 --o bind8 bind8 --as--o v10