Uses spatial comparison to determine which county polygons the locations fall into and returns the county name strings for those polygons.
Specification of stateCodes limits spatial searching to the specified states and greatly improves performance.
stateCodes
If allData = TRUE, additional data is returned.
allData = TRUE
getUSCounty(lon, lat, dataset = "USCensusCounties", stateCodes = 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 stateCodes used to limit the search
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 county names in English.
http://www.naturalearthdata.com/downloads/10m-cultural-vectors/
getSpatialData
# NOT RUN { lon <- seq(-140, -90) lat <- seq(20, 70) getUSCounty(lon, lat) # }
Run the code above in your browser using DataLab