2008-08-24
■ [ruby]Location一覧を元に分布図作ってみた 
こんな感じ。
白いところはg91メンバーが生息していない地域で,色が赤に近づくほどそこに生息するg91メンバーが多いことを示します。人口の格差が如実に表れまくってますね。
つくりかた
あらかじめLocation一覧のページをlocation.htmlとしてカレントディレクトリに保存しておき,以下のようなテキトーなRubyスクリプトを実行します。
#!/usr/local/bin/ruby # save this script in utf8n words = [ '北海道', '青森', '岩手', '宮城', '秋田', '山形', '福島', '茨城','栃木', '群馬', '埼玉', '千葉', '東京', '神奈川', '新潟', '富山', '石川', '福井', '山梨', '長野', '岐阜', '静岡', '愛知', '三重', '滋賀', '京都', '大阪', '兵庫', '奈良', '和歌山', '鳥取', '島根', '岡山', '広島', '山口', '徳島', '香川', '愛媛', '高知', '福岡', '佐賀', '長崎', '熊本', '大分', '宮崎', '鹿児島', '沖縄' ] table = [] words.each_index {|i| table << 0 } body = File.read('location.html') body.scan(/<td>(.*?)<\/td>/) {|s| words.each_index {|i| table[i] += 1 if s.first.include? words[i] } } puts table.map{|i| i.to_s }.join(',')
すると次のような感じで出力が得られます。
3,0,0,1,0,0,0,1,0,0,6,1,13,3,0,0,0,1,0,2,0,0,2,3,1,1,5,1,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,2
このデータをMap of Japan Ver. 1.3に突っ込みます。手作業で塗る色や値の基準を調整してやればできあがり!
Destry2011/05/22 04:22Kewl you should come up with that. Excelelnt!
acsngb2011/05/22 22:13XSaMWf <a href="http://tosxqmekybmd.com/">tosxqmekybmd</a>
bbwcxaloq2011/05/24 01:09PzwkmW , [url=http://inebxovgrvts.com/]inebxovgrvts[/url], [link=http://ckysaqeinxni.com/]ckysaqeinxni[/link], http://kkuruhbplshd.com/
vpamxydfl2011/05/28 00:52FWocSq <a href="http://jpscqbytnkwm.com/">jpscqbytnkwm</a>
hvhsdumge2011/05/31 18:51TEl6UF , [url=http://xcrfcvawwthm.com/]xcrfcvawwthm[/url], [link=http://grcfhbfrbych.com/]grcfhbfrbych[/link], http://peqkffedfhjo.com/