R语言画中国地图

用R画中国地图

准备工作

  1. R版本:4.0.5
  2. RStudio
  3. 中国国界线文件,各省市的经纬度文件
    链接:https://pan.baidu.com/s/1ANa4rMZxuXLgle-j-mruVw
    提取码:1010
  4. 代码
 install.packages("maptools")
install.packages("rgdal")#我之前下载的,具体这两个包有无其他依赖包,看提示
library(maptools)
library(rgdal)
#调取国际线文件(三个bou2_4p.文件必须放在同一个文件夹里)
str.crs <- " +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
china <- readShapePoly("M:/temp/geo/china_border/bou2_4p.shp", proj4string = CRS(str.crs))
#绘制中国地图,给不同省标上不同颜色(颜色可以自己换)
par(mar = c(2, 2, 0.1, 0.1))
plot(china,col=c("peachpuff","papayawhip","tan1","tan2","tomato"),
     ylim = c(18, 54), panel.first = grid());
#添加省会城市
city=read.csv("M:/temp/geo/china_city/city.csv",header=T, sep=",",encoding = "UTF-8")
points(city$jd,city$wd,pch=19,col="black")
text(city$jd, city$wd, city[,1], cex = 0.6, col = rgb(0,0, 0, 0.7), pos = c(2, 4, 4, 4, 3, 4, 2, 3, 4, 2, 4, 2, 2,
4, 3, 2, 1, 3, 1, 1, 2, 3, 2, 2, 1, 2, 4, 3, 1, 2, 2, 4, 4, 2))

结果显示

在这里插入图片描述

  • 0
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值