R语言画地图

分类: R语言与数理统计 |
1:使用的地图包有:library(mapdata),该包可以画中国地图、新西兰地图、日本地图、主要河流可以作为library(maps)包的补偿
北 京,116.4666667,39.9
上 海,121.4833333,31.23333333
天 津,117.1833333,39.15
重 庆,106.5333333,29.53333333")
library(maps)
library(mapdata)
map("china", col = "red4", ylim = c(18, 54), panel.first = grid())
title(" 中国地图")
china来自mapdata包,map函数来自maps包
2:
dat = read.csv(text =
"城市,jd,wd
library(maps)
library(mapdata)
map("china", col = "darkgray",
ylim = c(18, 54), panel.first = grid())
points(dat$jd, dat$wd, pch = 19,
col = rgb(0, 0, 0, 0.5),, cex = c(1,2,3,4))
结果如下:
参考链接:
http://cos.name/2013/01/drawing-map-in-r-era/
http://www.molecularecologist.com/2012/09/making-maps-with-r/