生活随笔
收集整理的這篇文章主要介紹了
R语言画中国地图
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
用R畫中國地圖
準(zhǔn)備工作
R版本:4.0.5RStudio中國國界線文件,各省市的經(jīng)緯度文件
鏈接:https://pan.baidu.com/s/1ANa4rMZxuXLgle-j-mruVw
提取碼:1010代碼
install.packages
("maptools")
install.packages
("rgdal")
library
(maptools
)
library
(rgdal
)
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))
結(jié)果顯示
總結(jié)
以上是生活随笔為你收集整理的R语言画中国地图的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。