2017-03-08 104 views
1

我想画国家,突出他们的沿海边界。我有以下技术,其中几乎可以工作如何画国家的沿海边界

library(rworldmap) 
library(rgeos) 
library(maps) 

data("countriesCoarseLessIslands") 
data("coastsCoarse") 

country <- "Argentina" 

countryOutline <- countriesCoarseLessIslands[countriesCoarseLessIslands$NAME %in% country,] 
maps::map(countryOutline,col="light grey",fill=TRUE,border=0) 
coastalBorder <- gIntersection(coastsCoarse,countryOutline) 
plot(coastalBorder, col="blue",lwd=2,add=TRUE) 

输出:

enter image description here

有两个方面,我想提高。

首先,我该如何摆脱海岸的不连续性(请参阅阿根廷的图片)。是否有一个函数或方法(在rgeos或其他地方)允许确定重叠的模糊性?

其次,我该如何做一些类似的更高分辨率的地图多边形?

回答

0

你的做法是很细的,你只需要减少使用setScale规模,为gIntersection更加宽容:

library(rworldmap) 
library(rgeos) 
library(maps) 

data("countriesCoarseLessIslands") 
data("coastsCoarse") 

country <- "Argentina" 

countryOutline <- countriesCoarseLessIslands[countriesCoarseLessIslands$NAME %in% country,] 
maps::map(countryOutline,col="light grey",fill=TRUE,border=0) 

setScale(1e+04) # Change Tolerance to avoid dicontinuities 

coastalBorder <- gIntersection(coastsCoarse,countryOutline) 
plot(coastalBorder, col="blue",lwd=2,add=TRUE) 

enter image description here

+0

谢谢了。没有注意到设置容差的能力。 – avsmith