getUSCounty: Return US county name at specified locations

View source: R/getUSCounty.R

getUSCountyR Documentation

Return US county name at specified locations

Description

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.

Usage

getUSCounty(
  longitude = NULL,
  latitude = NULL,
  dataset = "USCensusCounties",
  stateCodes = NULL,
  allData = FALSE,
  useBuffering = FALSE
)

Arguments

longitude

Vector of longitudes in decimal degrees East.

latitude

Vector of latitudes in decimal degrees North.

dataset

Name of spatial dataset to use.

stateCodes

Vector of US state codes used to limit the search.

allData

Logical specifying whether a full dataframe should be returned.

useBuffering

Logical flag specifying the use of location buffering to find the nearest polygon if no target polygon is found.

Value

Vector of English language county names.

References

http://www.naturalearthdata.com/downloads/10m-cultural-vectors/

See Also

getSpatialData

Examples

## Not run: 
library(MazamaSpatialUtils)
setSpatialDataDir("~/Data/Spatial_0.8")

loadSpatialData("USCensusCounties")

longitude <- seq(-140, -90)
latitude <- seq(20, 70)
getUSCounty(longitude, latitude)

## End(Not run)


MazamaSpatialUtils documentation built on Sept. 8, 2023, 5:22 p.m.