2017-03-08 103 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