R語言繪制地圖實(shí)例講解
更新時(shí)間:2021年03月17日 16:56:57 作者:小蝦米2018
這篇文章主要介紹了R語言繪制地圖實(shí)例講解,文中代碼實(shí)例講解的很清晰,有需要的可以研究下
setwd("C:/Users/75377/Desktop/SHEEP_ROH")
png("12.png",width = 7000,height = 5500,pointsize = 170)
par(mai = c(12,12,12,12),mgp = c(2.1,0.5,0))
#地圖數(shù)據(jù)下載http://cos.name/wp-content/uploads/2009/07/chinaprovinceborderdata_tar_gz.zip
library(maptools)
x <- readShapePoly ( 'bou2_4p.shp' )
plot(x,xlim=c(70,138),ylim = c(25, 45), lwd = 12,
,panel.first = grid(lwd=10))
axis(1,lwd=20,font = 2,cex.axis=1.3,tcl=-0.3)
axis(2,lwd=20,font = 2,cex.axis=1.3,tcl=-0.3)
axis(3,lwd=20,font = 2,cex.axis=1.3,tcl=-0.3)
axis(4,lwd=20,font = 2,cex.axis=1.3,tcl=-0.3)
box(which = "plot",lwd=20)
library(REmap)
options(remap.ak = "個(gè)人秘鑰")
city_vec = c("北京","上海","廣州","深圳","重慶")
pos <- get_geo_position (city_vec)
pos
points(pos$lon,pos$lat, pch= c(15,16,17,25,18),bg = "green",
cex=c(1.3,1.3,1.3,1.3,2),
col=c("red","cyan","blue","green","purple"))
pos$lon <- as.numeric(pos$lon)
pos$lat <- as.numeric(pos$lat)
text(x = pos$lon[1]+2.5, y = pos$lat[1], labels = "AA",
font = 2,col="red",cex=0.7)
text(x = pos$lon[2]+2.5, y = pos$lat[2], labels = "BB",
font = 2,col = "cyan",cex = 0.6)
text(x = pos$lon[3]+2.5, y = pos$lat[3]+0.5, labels = "CC",
font = 2,cex = 0.6,col = "blue")
text(x = pos$lon[4]+2.5, y = pos$lat[4]-0.5, labels = "DD",
font = 2,cex=0.6,col = "green")
text(x = pos$lon[5]+2.5, y = pos$lat[5], labels = "EE",
font = 2,cex=0.6,col = "purple")
legend("bottomright",c("AA","BB","CC","DD","EE"),inset = 0.04,
pch = c(15,16,17,25,18),cex=0.8,text.font = 2,
col=c("red","cyan","blue","green","purple"),
pt.bg ="green",box.lwd =15,pt.cex = c(1.2,1.4,1.2,1.2,1.9))
dev.off()

到此這篇關(guān)于R語言繪制地圖實(shí)例講解的文章就介紹到這了,更多相關(guān)R語言繪制地圖內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
R語言-生成頻數(shù)表和列聯(lián)表crosstable函數(shù)介紹
這篇文章主要介紹了R語言-生成頻數(shù)表和列聯(lián)表crosstable函數(shù)介紹,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2021-04-04
R語言統(tǒng)計(jì)結(jié)果輸出至本地文件的幾種方法示例
這篇文章主要給大家介紹了關(guān)于R語言統(tǒng)計(jì)結(jié)果輸出至本地文件的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-03-03
R語言模擬疫情傳播圖RVirusBroadcast展示疫情數(shù)據(jù)
本文用RVirusBroadcast展示模擬的疫情數(shù)據(jù),讓R語言模擬疫情傳播圖來告訴你為什么還不到出門的時(shí)候,有需要的朋友可以借鑒參考下,希望能夠有所幫助
2022-02-02 
