Last active
August 29, 2015 14:04
-
-
Save komasaru/07fa60f41d3b8c288a76 to your computer and use it in GitHub Desktop.
R script to generate a map by maptools.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ライブラリの読み込み | |
library(maptools) | |
library(RColorBrewer) | |
# Shape ファイルのフルパス | |
shp <- '/path/to/shapefile.shp' | |
# Shape ファイルの読み込み | |
# map <- readShapePoly(shp) # これでもよい | |
map <- readShapeSpatial(shp) | |
# 色設定 | |
#( RColorBrewer - Paired パレット の12色を21市町村分ランダムに設定する例 ) | |
col <- sample(1:12, size=21, replace=T) | |
# プロット | |
# ( x, y 軸表示、ラベル「全て水平」、RColorBrewer で塗りつぶし、 | |
# 境界線「青」、境界線太さ「1」 ) | |
plot(map, axes=T, las=1, col=brewer.pal(12,"Paired")[col], border="blue", lwd=1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment