2017-06-12 43 views
0

爲什麼map.where找不到這個GPS座標的正確縣?map.where返回NA

> maps::map.where('county', y = 47.9078 , x = -122.2803) 
[1] NA 

它適用於華盛頓的其他點。

> maps::map.where('county', y = 46.0900, x = -121.7600) 
[1] "washington,skamania" 

回答

1

我你看詳細,你會看到其實點落在外面所有多邊形:

> maps::map('county',xlim=c(-123,-122),ylim=c(47,48),fill=TRUE) 
> points(y = 47.9078 , x = -122.2803,col=2) 

enter image description here 所以NA結果是在這方面正常。由於縣地圖的分辨率有限,這當然可能是錯誤的。顯然,這一點非常接近或靠近海岸,也許更好的質量地圖可能會給出不同的結果。使用rnaturalearth你可以做一個類似的情節,這清楚地表明瞭區別:

library(rnaturalearth) 
cc=ne_states(iso_a2="US") 
maps::map(cc,xlim=c(-123,-122),ylim=c(47,48),fill=TRUE) 
points(y = 47.9078 , x = -122.2803,col=2) 
maps::map('county',xlim=c(-123,-122),ylim=c(47,48),add=TRUE,col=3) 

enter image description here