Find in which country each point-coordinate belong

2019-07-09 01:57发布

问题:

This question already has an answer here:

  • Convert latitude and longitude coordinates to country name in R 2 answers

I have a data frame with lat/lon coordinates:

head(COORD)
   LAT   LON 
1  69.34 16.17  
2  69.20 17.92   
3  69.59 17.87 
4  69.17 18.52  
5  69.42 18.95 
6  69.22 18.91 

I would like to to retrieve the country name of each point and add it as a third column. Maybe using which in combination with map to retrieve in which polygon the points are but I was not able to figure out how.

回答1:

Try using map.where()

library(maps)

COORD$Country <- map.where(database="world", COORD$LON, COORD$LAT)