Downloads and extracts shapefiles for either US states or counties. It creates a directory in the specified location if one does not exist already. The function downloads the shapefile from the specified URL, unzips it, reads it into an object of class 'sf', changes its projection to that of "EPSG:5070", fixes topology, matches state name with observation data and assigns unique identifiers.
Arguments
- unit
A character string indicating whether to download state or county borders, default is "state".
- proj
Projection for the shapefiles, defaults to "EPSG:5070".
Value
An object of class 'SpatialPolygonsDataFrame' which contains the state or county border polygons and their associated attributes.
Examples
#Download state boundaries to a directory called 'States':
download_boundaries("./States")
#> Error in paste0(su_yaml$out_dir_name, "/polygons"): object 'su_yaml' not found
#Download county boundaries to a directory called 'Counties':
download_boundaries("./Counties", unit = "county")
#> Error in paste0(su_yaml$out_dir_name, "/polygons"): object 'su_yaml' not found