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.
If allData = TRUE
, additional data is returned.
getUSCounty(
longitude = NULL,
latitude = NULL,
dataset = "USCensusCounties",
stateCodes = NULL,
allData = FALSE,
useBuffering = FALSE
)
Vector of longitudes in decimal degrees East.
Vector of latitudes in decimal degrees North.
Name of spatial dataset to use.
Vector of US state codes 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 English language county names.
http://www.naturalearthdata.com/downloads/10m-cultural-vectors/
getSpatialData
if (FALSE) {
library(MazamaSpatialUtils)
setSpatialDataDir("~/Data/Spatial_0.8")
loadSpatialData("USCensusCounties")
longitude <- seq(-140, -90)
latitude <- seq(20, 70)
getUSCounty(longitude, latitude)
}