Learn R Programming

MazamaSpatialUtils (version 0.8.6)

getUSCounty: 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
)

Value

Vector of English language county names.

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.

References

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

See Also

getSpatialData

Examples

Run this code
if (FALSE) {
library(MazamaSpatialUtils)
setSpatialDataDir("~/Data/Spatial_0.8")

loadSpatialData("USCensusCounties")

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

Run the code above in your browser using DataLab