在使用R创建的地理地图中填充大陆区域

在使用R创建的地理地图中填充大陆区域,r,geolocation,maps,plot,geocoding,R,Geolocation,Maps,Plot,Geocoding,我尝试使用R中的maps包创建地理地图。我不确定这是否是“首选包” 我试图用蓝色背景、白色大陆区域和红色国家边界绘制一幅世界地图。但是,似乎不可能在不以黑色划定国家边界的情况下填充区域。我犯了什么错 library(maps) # Show the World map without country border, # with black continent boundaries on a bluish background map("world", interior=F, boundar

我尝试使用R中的maps包创建地理地图。我不确定这是否是“首选包”

我试图用蓝色背景、白色大陆区域和红色国家边界绘制一幅世界地图。但是,似乎不可能在不以黑色划定国家边界的情况下填充区域。我犯了什么错

library(maps)

# Show the World map without country border,
# with black continent boundaries on a bluish background 
map("world", interior=F, boundary=T, bg="#ddeeff", col="black")

# Fill continental areas in white
map("world", col="white", interior=F, fill=TRUE, add=T)

# Add country borders in red
map("world", interior=T, boundary=F, col="red", add=T)
使用
?map
可以提供:

填充-表示是绘制直线还是填充区域的逻辑标志。如果为FALSE,将绘制每个区域的边界线(但对于内部线,仅绘制一次)。如果为TRUE,将使用col=参数中的颜色填充每个区域,并且不会绘制边界线

我的R版本是:

平台x86_64-apple-darwin9.8.0
拱门x86_64
操作系统达尔文9.8.0
系统x86_64,达尔文9.8.0
状态
专业2
小调13.0
2011年
第04个月
第13天
svn版次55427
语言R
version.string R版本2.13.0(2011-04-13)

使用基本图形: (在黑色边界的顶部有一定数量的红色过度涂绘-我找不到一种完全消除这种情况的方法。)

使用
ggplot
: (使用
ggplot
您可以完全控制所有颜色,并且不会出现过度绘制。但渲染需要更长的时间…)

库(ggplot2)
图书馆(地图)

mapWorld使用基本图形:

为了避免过度抽签,您可以在第一次调用中将
lty
参数设置为0,以填充国家,而不绘制黑色边界

library(maps)   
map("world", interior=TRUE, fill=TRUE, boundary=FALSE, col="white", lty=0, bg="lightblue")
map("world", interior=TRUE, boundary=TRUE, col="red", add=TRUE)

可以在单个“映射”命令中更改边框的颜色:

map("world", fill=TRUE, col="white", bg="lightblue", border="red")
“border='red'”选项没有明确记录在“?map”中,因为它实际上是直接用于“polygon()”的选项,该选项是从map()内部调用的。它是map()调用中“…”的一部分

library(maps)   
map("world", interior=TRUE, fill=TRUE, boundary=FALSE, col="white", lty=0, bg="lightblue")
map("world", interior=TRUE, boundary=TRUE, col="red", add=TRUE)
map("world", fill=TRUE, col="white", bg="lightblue", border="red")