Ficheru:SwedishGeneralElection2010-map.svg

Ficheru orixinal(ficheru SVG, 290 × 654 píxels nominales, tamañu de ficheru: 262 kB)

Esti ficheru ye de Wikimedia Commons y puen usalu otros proyeutos. La descripción de la páxina de descripción del ficheru s'amuesa darréu.

Descripción
English: Swedish general election 2010 relative coalition support breakdown by municipality. Although the Red-Greens are dominant on a wider area, the urban population of South decided the election for the Alliance. The data has been fed through a Laplace distribution function to make the regional differences seem more pronounced. Support is relative to all votes cast to one of the seven coalition parties. Open the image in browser for overall statistics.

Key: 00 The Alliance dominance 00 Red-Green dominance 00 Equal dominance

Based on SWE-Map Kommuner2007.svg de Lokal_Profil, scripted with Nokogiri  de Hydrox.
Data
Fonte Trabayu propiu basáu en: SWE-Map Kommuner2007.svg de Lokal_Profil
Autor Hydrox
Permisu
(Cómo reutilizar esti ficheru)
w:es:Creative Commons
reconocimientu compartir igual
Este archivo se encuentra bajo la licencia Creative Commons Genérica de Atribución/Compartir-Igual 2.5.
Ye llibre:
  • pa compartir – pa copiar, distribuir y comunicar públicamente la obra
  • pa remezclar – p'adautar la obra
Baxo les condiciones siguientes:
  • reconocimientu – Tienes de dar el créitu apropiáu, apurrir un enllaz a la llicencia ya indicar si realizasti dalgún cambéu. Puedes faelo de cualquier mou razonable ,pero non de manera que suxera l'encontu del autor pa ti o pal usu que faigas.
  • compartir igual – Si entemeces, tresformes o te bases nesti material, tienes de distribuir les tos contribuciones baxo la mesma llicencia o una compatible cola orixinal.
Otres versiones File:SwedishGeneralElection2010-map-SwedenDemocrats.svg – Breakdown of relative support to Sweden Democrats, the only elected non-coalition party.
SVG desarrollo
InfoField
 
El código fuente de esta imagen SVG es inválido por 290 errores.
 
Este mapa, inválido según el W3C, fue creado con Inkscape.

Source code

SweMap.rb
require "SweMapDB.rb"

# How to use this script in Ubuntu:
# 1) sudo aptitude install ruby1.8 libnokogiri-ruby
# 2) Place SweMapDB.rb and the source map in the same directory as this script.
# 3) Download regional ballots from the Election Authority:
#   for i in `seq 1 9`; do
#     wget -O $i.html "http://www.val.se/val/val2010/slutresultat/R/rvalkrets/0$i/index.html"
#   done
#   for i in `seq 10 29`; do
#     wget -O $i.html "http://www.val.se/val/val2010/slutresultat/R/rvalkrets/$i/index.html"
#   done
# 4) ruby1.8 SweMap.rb


# Set source map
MAP = SweMap.load "SWE-Map_Kommuner2007.svg"

# Laplace function parameters
MU = 0.5
B = 0.15
def lcdf(x)
  return 0.5 * Math.exp((x-MU) / B) if x < MU
  return 1 - 0.5 * Math.exp((-x+MU)/B)
end

def color(kommun, right, left, total)
  r = 0xff * lcdf((left.to_f / total))
  b = 0xff * lcdf((right.to_f / total))
  MAP.style kommun, "fill", "rgb(#{r.round}, 0, #{b.round})"
end

kommunf = Hash.new { |hash, key| key }
kommunf['Malung-Sälen'] = 'Malung'
kommunf['I vallokal ej räknade röster'] = false

parties = %w(M, C, FP, KD, S, V, MP, SD, ÖVR, BLANK, OG)

(1..29).each do |v|
  fn = "#{v}.html"
  doc = Nokogiri::HTML(open(fn))
  doc.errors.each { |e| raise "Parse error in #{fn}" if e.fatal? }
  if [1,9,11,16].include? v
    table = doc.css('table [class="sorteringsbar_tabell"]')[1].css "tbody:last-child"
    summa = true
  else
    table = doc.css('table >tbody[class="sorteringsbara_rader"]')[1]
    summa = false
  end
  raise "No table!" if not table
  table.children.each do |row|
    if row.elem?
      if summa
        kommun = kommunf[row.at_css('td:first-child').inner_text]
        if v >= 10
          link = "http://www.val.se/val/val2010/slutresultat/R/rvalkrets/#{v}/index.html"
        else
          link = "http://www.val.se/val/val2010/slutresultat/R/rvalkrets/0#{v}/index.html"
        end
      else
        a = row.at_css('td:first-child a')
        kommun = kommunf[]["title"]
        link = "http://www.val.se/val/val2010/slutresultat/R/rvalkrets/#{v}/" + a["href"]
      end
      if kommun
        right = left = sd = ovr = blank = og = total = 0
        row.css("td.relativ_nej").each_with_index do |e,i|
          n = e.inner_text.to_i
          if i <= 3
            right += n
          elsif i <= 6
            left += n
          elsif i == 7
            sd = n
          elsif i == 8
            ovr = n
          elsif i == 9
            blank = n
          elsif i == 10
            og = n
          elsif i == 11
            total = n
          end
        end
        color kommun, right, left, total-blank-og-sd-ovr
        MAP.link kommun, link, "#{kommun} / "+
            "AL: #{(1000.0 * right/(total-blank-og)).round / 10.0}% " +
            "RG: #{(1000.0 *  left/(total-blank-og)).round / 10.0}%"
      end
    end
  end
end

MAP.write("SwedishGeneralElection2010-map.svg")
SweMapDB.rb
begin
  require "rubygems"
rescue LoadError
end
require "nokogiri"

SCB = {
  "AB" => {
    "0114" => "Upplands Väsby",
    "0115" => "Vallentuna",
    "0117" => "Österåker",
    "0120" => "Värmdö",
    "0123" => "Järfälla",
    "0125" => "Ekerö",
    "0126" => "Huddinge",
    "0127" => "Botkyrka",
    "0128" => "Salem",
    "0136" => "Haninge",
    "0138" => "Tyresö",
    "0139" => "Upplands-Bro",
    "0140" => "Nykvarn",
    "0160" => "Täby",
    "0162" => "Danderyd",
    "0163" => "Sollentuna",
    "0180" => "Stockholm",
    "0181" => "Södertälje",
    "0182" => "Nacka",
    "0183" => "Sundbyberg",
    "0184" => "Solna",
    "0186" => "Lidingö",
    "0187" => "Vaxholm",
    "0188" => "Norrtälje",
    "0191" => "Sigtuna",
    "0192" => "Nynäshamn"
  },
  "C" => {
    "0305" => "Håbo",
    "0319" => "Älvkarleby",
    "0330" => "Knivsta",
    "0331" => "Heby",
    "0360" => "Tierp",
    "0380" => "Uppsala",
    "0381" => "Enköping",
    "0382" => "Östhammar"
  },
  "D" => {
    "0428" => "Vingåker",
    "0461" => "Gnesta",
    "0480" => "Nyköping",
    "0481" => "Oxelösund",
    "0482" => "Flen",
    "0483" => "Katrineholm",
    "0484" => "Eskilstuna",
    "0486" => "Strängnäs",
    "0488" => "Trosa"
  },
  "E" => {
    "0509" => "Ödeshög",
    "0512" => "Ydre",
    "0513" => "Kinda",
    "0560" => "Boxholm",
    "0561" => "Åtvidaberg",
    "0562" => "Finspång",
    "0563" => "Valdemarsvik",
    "0580" => "Linköping",
    "0581" => "Norrköping",
    "0582" => "Söderköping",
    "0583" => "Motala",
    "0584" => "Vadstena",
    "0586" => "Mjölby"
  },
  "F" => {
    "0604" => "Aneby",
    "0617" => "Gnosjö",
    "0642" => "Mullsjö",
    "0643" => "Habo",
    "0662" => "Gislaved",
    "0665" => "Vaggeryd",
    "0680" => "Jönköping",
    "0682" => "Nässjö",
    "0683" => "Värnamo",
    "0684" => "Sävsjö",
    "0685" => "Vetlanda",
    "0686" => "Eksjö",
    "0687" => "Tranås"
  },
  "G" => {
    "0760" => "Uppvidinge",
    "0761" => "Lessebo",
    "0763" => "Tingsryd",
    "0764" => "Alvesta",
    "0765" => "Älmhult",
    "0767" => "Markaryd",
    "0780" => "Växjö",
    "0781" => "Ljungby"
  },
  "H" => {
    "0821" => "Högsby",
    "0834" => "Torsås",
    "0840" => "Mörbylånga",
    "0860" => "Hultsfred",
    "0861" => "Mönsterås",
    "0862" => "Emmaboda",
    "0880" => "Kalmar",
    "0881" => "Nybro",
    "0882" => "Oskarshamn",
    "0883" => "Västervik",
    "0884" => "Vimmerby",
    "0885" => "Borgholm"
  },
  "I" => {
    "0980" => "Gotland"
  },
  "K" => {
    "1060" => "Olofström",
    "1080" => "Karlskrona",
    "1081" => "Ronneby",
    "1082" => "Karlshamn",
    "1083" => "Sölvesborg"
  },
  "M" => {
    "1214" => "Svalöv",
    "1230" => "Staffanstorp",
    "1231" => "Burlöv",
    "1233" => "Vellinge",
    "1256" => "Östra Göinge",
    "1257" => "Örkelljunga",
    "1260" => "Bjuv",
    "1261" => "Kävlinge",
    "1262" => "Lomma",
    "1263" => "Svedala",
    "1264" => "Skurup",
    "1265" => "Sjöbo",
    "1266" => "Hörby",
    "1267" => "Höör",
    "1270" => "Tomelilla",
    "1272" => "Bromölla",
    "1273" => "Osby",
    "1275" => "Perstorp",
    "1276" => "Klippan",
    "1277" => "Åstorp",
    "1278" => "Båstad",
    "1280" => "Malmö",
    "1281" => "Lund",
    "1282" => "Landskrona",
    "1283" => "Helsingborg",
    "1284" => "Höganäs",
    "1285" => "Eslöv",
    "1286" => "Ystad",
    "1287" => "Trelleborg",
    "1290" => "Kristianstad",
    "1291" => "Simrishamn",
    "1292" => "Ängelholm",
    "1293" => "Hässleholm"
  },
  "N" => {
    "1315" => "Hylte",
    "1380" => "Halmstad",
    "1381" => "Laholm",
    "1382" => "Falkenberg",
    "1383" => "Varberg",
    "1384" => "Kungsbacka"
  },
  "O" => {
    "1401" => "Härryda",
    "1402" => "Partille",
    "1407" => "Öckerö",
    "1415" => "Stenungsund",
    "1419" => "Tjörn",
    "1421" => "Orust",
    "1427" => "Sotenäs",
    "1430" => "Munkedal",
    "1435" => "Tanum",
    "1438" => "Dals-Ed",
    "1439" => "Färgelanda",
    "1440" => "Ale",
    "1441" => "Lerum",
    "1442" => "Vårgårda",
    "1443" => "Bollebygd",
    "1444" => "Grästorp",
    "1445" => "Essunga",
    "1446" => "Karlsborg",
    "1447" => "Gullspång",
    "1452" => "Tranemo",
    "1460" => "Bengtsfors",
    "1461" => "Mellerud",
    "1462" => "Lilla Edet",
    "1463" => "Mark",
    "1465" => "Svenljunga",
    "1466" => "Herrljunga",
    "1470" => "Vara",
    "1471" => "Götene",
    "1472" => "Tibro",
    "1473" => "Töreboda",
    "1480" => "Göteborg",
    "1481" => "Mölndal",
    "1482" => "Kungälv",
    "1484" => "Lysekil",
    "1485" => "Uddevalla",
    "1486" => "Strömstad",
    "1487" => "Vänersborg",
    "1488" => "Trollhättan",
    "1489" => "Alingsås",
    "1490" => "Borås",
    "1491" => "Ulricehamn",
    "1492" => "Åmål",
    "1493" => "Mariestad",
    "1494" => "Lidköping",
    "1495" => "Skara",
    "1496" => "Skövde",
    "1497" => "Hjo",
    "1498" => "Tidaholm",
    "1499" => "Falköping"
  },
  "S" => {
    "1715" => "Kil",
    "1730" => "Eda",
    "1737" => "Torsby",
    "1760" => "Storfors",
    "1761" => "Hammarö",
    "1762" => "Munkfors",
    "1763" => "Forshaga",
    "1764" => "Grums",
    "1765" => "Årjäng",
    "1766" => "Sunne",
    "1780" => "Karlstad",
    "1781" => "Kristinehamn",
    "1782" => "Filipstad",
    "1783" => "Hagfors",
    "1784" => "Arvika",
    "1785" => "Säffle"
  },
  "T" => {
    "1814" => "Lekeberg",
    "1860" => "Laxå",
    "1861" => "Hallsberg",
    "1862" => "Degerfors",
    "1863" => "Hällefors",
    "1864" => "Ljusnarsberg",
    "1880" => "Örebro",
    "1881" => "Kumla",
    "1882" => "Askersund",
    "1883" => "Karlskoga",
    "1884" => "Nora",
    "1885" => "Lindesberg"
  },
  "U" => {
    "1904" => "Skinnskatteberg",
    "1907" => "Surahammar",
    "1960" => "Kungsör",
    "1961" => "Hallstahammar",
    "1962" => "Norberg",
    "1980" => "Västerås",
    "1981" => "Sala",
    "1982" => "Fagersta",
    "1983" => "Köping",
    "1984" => "Arboga"
  },
  "W" => {
    "2021" => "Vansbro",
    "2023" => "Malung",
    "2026" => "Gagnef",
    "2029" => "Leksand",
    "2031" => "Rättvik",
    "2034" => "Orsa",
    "2039" => "Älvdalen",
    "2061" => "Smedjebacken",
    "2062" => "Mora",
    "2080" => "Falun",
    "2081" => "Borlänge",
    "2082" => "Säter",
    "2083" => "Hedemora",
    "2084" => "Avesta",
    "2085" => "Ludvika"
  },
  "X" => {
    "2101" => "Ockelbo",
    "2104" => "Hofors",
    "2121" => "Ovanåker",
    "2132" => "Nordanstig",
    "2161" => "Ljusdal",
    "2180" => "Gävle",
    "2181" => "Sandviken",
    "2182" => "Söderhamn",
    "2183" => "Bollnäs",
    "2184" => "Hudiksvall"
  },
  "Y" => {
    "2260" => "Ånge",
    "2262" => "Timrå",
    "2280" => "Härnösand",
    "2281" => "Sundsvall",
    "2282" => "Kramfors",
    "2283" => "Sollefteå",
    "2284" => "Örnsköldsvik"
  },
  "Z" => {
    "2303" => "Ragunda",
    "2305" => "Bräcke",
    "2309" => "Krokom",
    "2313" => "Strömsund",
    "2321" => "Åre",
    "2326" => "Berg",
    "2361" => "Härjedalen",
    "2380" => "Östersund"
  },
  "AC" => {
    "2401" => "Nordmaling",
    "2403" => "Bjurholm",
    "2404" => "Vindeln",
    "2409" => "Robertsfors",
    "2417" => "Norsjö",
    "2418" => "Malå",
    "2421" => "Storuman",
    "2422" => "Sorsele",
    "2425" => "Dorotea",
    "2460" => "Vännäs",
    "2462" => "Vilhelmina",
    "2463" => "Åsele",
    "2480" => "Umeå",
    "2481" => "Lycksele",
    "2482" => "Skellefteå"
  },
  "BD" => {
    "2505" => "Arvidsjaur",
    "2506" => "Arjeplog",
    "2510" => "Jokkmokk",
    "2513" => "Överkalix",
    "2514" => "Kalix",
    "2518" => "Övertorneå",
    "2521" => "Pajala",
    "2523" => "Gällivare",
    "2560" => "Älvsbyn",
    "2580" => "Luleå",
    "2581" => "Piteå",
    "2582" => "Boden",
    "2583" => "Haparanda",
    "2584" => "Kiruna"
  }
}

LAN = {
  "stockholm" => "A",
  "uppsala" => "C",
  "södermanland" => "D",
  "östergötland" => "E",
  "jönköping" => "F",
  "kronoberg" => "G",
  "kalmar" => "H",
  "gotland" => "I",
  "blekinge" => "K",
  "skåne" => "M",
  "halland" => "N",
  "västra götaland" => "O",
  "värmland" => "S",
  "örebro" => "T",
  "västmanland" => "U",
  "dalarna" => "W",
  "gävleborg" => "X",
  "västernorrland" => "Y",
  "jämtland" => "Z",
  "västerbotten" => "AC",
  "norrbotten" => "BD"
}

class SweMap
  
  public
  def self.load(filename, mode=:kommuns)
    begin
      return self.new(filename, mode)
    rescue
      error
    end
  end

  def style(name, attribute, value)
    begin
      set_style(get_element(name), attribute, value)
    rescue
      error
    end
  end
  
  def link(name, url, title=nil)
    begin
      link_to(get_element(name), url, title)
    rescue
      error
    end
  end
 
  def write(filename)
    begin
      open(filename, "w") { |f| @doc.write_to(f, :encoding => 'UTF-8') }
    rescue
      error
    end
  end

  private
  def initialize(filename, mode)
    @mode = mode
    open(filename) { |f| @doc = Nokogiri::XML(f) }
    raise "Could not find #{filename}" if @doc === nil

    @doc.errors.each { |e| raise "Parse error in #{filename}" if e.fatal? }

    @doc.root['xmlns:xlink'] = "http://www.w3.org/1999/xlink"

    if @mode == :kommuns
      @BCS = {}
      SCB.each_value {|h| h.each_pair { |c,k| @BCS[k.downcase] = c } }
    end
  end

  def get_element(name)
    if @mode == :kommuns
      id = get_kommun_id(name)
    else
      id = get_county_id(name)
    end

    el = @doc.at_css "*[id=\"#{id}\"]"
    if not (el and el.elem?)
      raise "Could not find id=\"#{id}\" in the SVG!"
    end

    return el
  end

  def get_kommun_id(kommun)
    if kommun.is_a? Fixnum
      id = "0" * (4-Math.log10(kommun+1).ceil) + kommun.to_s
    else
      id = @BCS[kommun.to_s.strip.downcase]
    end

    if not id
      raise "Where is '#{kommun}'? Check that you have the right name."
    end

    return id
  end

  def get_county_id(county)
    county = county.to_s
    
    if county.length > 2
      s = county.downcase
      id = LAN[s]
      id = LAN["#{s}s"] if not id
      if not id
        raise "Where is '#{county}'? Check that you have the right name."
      end
      return id
    else
      return county
    end
  end
  
  def set_style(group, attribute, value)
    re = Regexp.new "#{Regexp.quote(attribute)}\s*:[^;]*;"
    group.traverse do |el|
      if el.elem?
        if el.has_attribute? "style" and el["style"].strip.length > 0
          style = el["style"]
          if style.match re
            style = style.sub(re, "#{attribute}: #{value};")
          else
            style += " #{attribute}: #{value};"
          end
          el["style"] = style
        else
          el["style"] = "#{attribute}: #{value};"
        end
      end
    end
  end

  def link_to(el, url, title)
    par = @doc.create_element 'a'
    par["xlink:href"] = url
    par["xlink:title"] = title if title
    par.parent = el.parent
    el.parent = par
  end

  def error
    STDERR.puts "Error: #{$!}"
  end
end

Pies

Añade una explicación corta acerca de lo que representa este archivo

Elementos representados en este archivo

representa a

Historial del ficheru

Calca nuna fecha/hora pa ver el ficheru como taba daquella.

Data/HoraMiniaturaDimensionesUsuariuComentariu
actual06:25 26 set 2010Miniatura de la versión a fecha de 06:25 26 set 2010290 × 654 (262 kB)Hydrox{{Information |Description={{en|1=Swedish general election 2010 relative coalition support breakdown by municipality. Although the Red-Greens are dominant on a wider area, the urban population in South decided the election for the Alliance. The data has b

La páxina siguiente usa esti ficheru:

Usu global del ficheru

Estes otres wikis usen esti ficheru: