Rafael Martins -4 years ago 56
R Question

# map.where returning NA

Why isn't map.where finding the right county for this GPS coordinate?

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

It works for other points in Washington.

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

I you look in detail, you will see the point in fact falls just outside all polygons:

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

So the NA result is normal in that respect. It may of course be wrong due to the limited resolution of the county map. Clearly the point is very close to or on the coast, and maybe a better quality map may give a different result. Using `rnaturalearth` you can make a similar plot, which clearly shows the difference:

``````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)