本文主要是介绍R语言学习笔记:绘制地图,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
在R中画地图先从简单的maps包开始。
library("maps")
在这个maps包中有一些数据集,用命令data(package=”maps”),可以看到如下数据:
canada.cities Database of Canadian cities
county.fips FIPS county codes for US County Map
countyMapEnv United States County Map
franceMapEnv France Map
italyMapEnv Italy Map
nzMapEnv New Zealand Basic Map
ozone Sample datasets
state.carto.center United States State Population Cartogram Map
state.cartoMapEnv United States State Population Cartogram Map
state.fips FIPS state codes for US 48 State Map
state.vbm.center United States State Visibility Base Map
state.vbmMapEnv United States State Visibility Base Map
stateMapEnv United States State Boundaries Map
unemp Sample datasets
us.cities Database of US cities
usaMapEnv United States Coast Map
votes.repub Sample datasets
world.cities Database of world cities
world2MapEnv Pacific Centric Low resolution World Map
worldMapEnv Low resolution World Map
画出美国各州的边界:
map('state', panel.first=grid())
axis(1,lwd=0)
axis(2,lwd=0)
axis(3,lwd=0)
axis(4,lwd=0)
box()
标出美国的城市:
data(us.cities)
points(us.cities$long, us.cities$lat, pch=19)
标出人口大于一百万的城市
cities <- us.cities[us.cities$pop > 1000000,]
points(cities$long, cities$lat, pch=19)
text(cities$long, cities$lat, cities$name, col="blue", cex=0.8, pos=1)
这篇关于R语言学习笔记:绘制地图的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!