Uses spatial comparison to determine which country polygons the locations fall into and returns the country code strings for those polygons.
If allData = TRUE, additional data is returned.
allData = TRUE
getCountryCode(lon, lat, dataset = "SimpleCountriesEEZ", countryCodes = NULL, allData = FALSE, useBuffering = FALSE)
vector of longitudes in decimal degrees
vector of latitudes in decimal degrees
name of spatial dataset to use
vector of countryCodes
logical specifying whether a full dataframe should be returned
logical flag specifying the use of location buffering to find the nearest polygon if no target polygon is found
Vector of ISO-3166-1 alpha-2 country codes.
http://www.naturalearthdata.com/downloads/10m-cultural-vectors/
SimpleCountries
getSpatialData
# NOT RUN { lon <- seq(0, 50) lat <- seq(0, 50) getCountryCode(lon, lat) # }
Run the code above in your browser using DataLab