日本地図

高校「情報」教員採用試験状況

2015年6月に三重大学医学部看護学科教授になられた 谷村 晋 先生によるパッケージ Nippon を使って日本地図を描いてみる。

データは,神戸市立科学技術高等学校の 中野 由章 先生が毎年調べられている高校「情報」教員採用試験状況である。

まずNipponパッケージのインストール:

install.packages(c("rgeos", "Nippon"))

2016年度の高校「情報」教員採用試験で,副免許不要の都道府県は青,副免許必要の都道府県は黄を塗る。

library(Nippon)
data(prefectures)
cols = rep("white", 47)
names(cols) = sub("[都府県]$", "", prefectures$name)
cols[c("三重","大阪","岡山","広島","沖縄")] = "blue"
cols[c("福島","埼玉","千葉","東京","神奈川","富山","長野","愛知","兵庫","奈良","山口")] = "yellow"
par(mar=c(0,0,0,0)) # 下左上右マージン。初期値 c(5,4,4,2)+0.1
JapanPrefecturesMap(col=cols)
legend(141, 33, c("副免許不要","副免許必要"), fill=c("blue","yellow"))
2016年度高校「情報」教員採用試験状況

「白いところは何なんですか?」とよく尋ねられる。「採用なし」である。ちなみに,高校「情報」は必履修の教科である。

アニメーション化

ついでに,中野先生のページから副免許の要・不要も書き込まれたデータをすべていただいてきて,アニメーションで表示する:

year = 2001:2016
cols = matrix(rep("white", 47*16), nrow=47)
rownames(cols) = sub("[都府県]$", "", prefectures$name)

cols[c("三重","大阪","岡山","広島","沖縄"), 16] = "blue"
cols[c("福島","埼玉","千葉","東京","神奈川","富山","長野","愛知","兵庫","奈良","山口"), 16] = "yellow"

cols[c("山形","大阪","広島","熊本","沖縄"), 15] = "blue"
cols[c("福島","埼玉","千葉","東京","神奈川","富山","長野","愛知","兵庫","山口","香川"), 15] = "yellow"

cols[c("静岡","岐阜","三重","大阪","広島","大分","沖縄"), 14] = "blue"
cols[c("福島","埼玉","千葉","東京","神奈川","長野","富山","愛知","兵庫","山口"), 14] = "yellow"

cols[c("山形","静岡","岐阜","三重","大阪","広島","沖縄"), 13] = "blue"
cols[c("埼玉","千葉","東京","神奈川","富山","愛知","奈良","兵庫","山口","香川"), 13] = "yellow"

cols[c("山形","静岡","大阪","岡山","広島","大分","宮崎","沖縄"), 12] = "blue"
cols[c("埼玉","千葉","東京","神奈川","富山","愛知","兵庫"), 12] = "yellow"

cols[c("静岡","三重","大阪","岡山","広島","沖縄"), 11] = "blue"
cols[c("山形","埼玉","東京","神奈川","富山","山梨","愛知","兵庫","奈良"), 11] = "yellow"

cols[c("静岡","大阪","広島","熊本","沖縄"), 10] = "blue"
cols[c("山形","群馬","埼玉","神奈川","富山","愛知","兵庫","鳥取"), 10] = "yellow"

cols[c("静岡","大阪","広島","沖縄"), 9] = "blue"
cols[c("山形","茨城","群馬","埼玉","神奈川","富山","愛知","鳥取"), 9] = "yellow"

cols[c("神奈川","静岡","大阪","大分","沖縄"), 8] = "blue"
cols[c("茨城","群馬","埼玉","東京","富山","愛知","鳥取"), 8] = "yellow"

library(animation)
saveGIF({
    for (i in 8:16) {
        JapanPrefecturesMap(col=cols[,i])
        title(year[i])
        legend(141, 33, c("副免許不要","副免許必要"), fill=c("blue","yellow"))
    }
})
高校で「情報」教員が採用された都道府県

投影法の変更

JapanPrefecturesMap() を少々改造し,投影法をUTM 54Nに変えてみる。座標変換は rgdal パッケージの spTransform() を使う。

JapanPrefecturesMap2 <- function (col = NULL, inset = TRUE, ...) 
{
    m <- readShapePoly(system.file("shapes/jpn.shp", package = "Nippon")[1], 
        proj4string = CRS("+proj=longlat +datum=WGS84"))
    if (inset) {
        xy.okinawa <- m@polygons[[47]]@Polygons[[1]]@coords
        xy.okinawa[, 1] <- xy.okinawa[, 1] + 7
        xy.okinawa[, 2] <- xy.okinawa[, 2] + 14
        m@polygons[[47]]@Polygons[[1]]@coords <- xy.okinawa
        labpt <- m@polygons[[47]]@labpt
        labpt[1] <- labpt[1] + 7
        labpt[2] <- labpt[2] + 14
        m@polygons[[47]]@labpt <- labpt
        m@bbox[1, 1] <- 130
        m@bbox[2, 1] <- 31
    }
    m <- spTransform(m, CRS("+proj=utm +zone=54 +datum=WGS84 +units=km"))
    plot(m, col = col, ...)
    if (inset) {
        lines(x = c(-300, 0, 200, 200), y = c(4250, 4250, 4500, 4800))
    }
    return(invisible(coordinates(m)))
}

これで描いてみる。座標は経度/緯度ではなくEasting/Northing (km)になることに注意する(axes=TRUE を付けるとわかりやすい)。

JapanPrefecturesMap2(col=cols)
legend(500, 3700, c("副免許不要","副免許必要"), fill=c("blue","yellow"))
2016年度高校「情報」教員採用試験状況

参考文献