Skip to contents

Get Counties boundaries via API, to map them

Usage

shapes_counties_from_countyfips(
  countyfips = "10001",
  outFields = c("NAME", "FIPS", "STATE_ABBR", "STATE_NAME", "POP_SQMI"),
  myservice =
    c("https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/services/USA_Boundaries_2022/FeatureServer/2/query",
    "https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/services/USA_Counties_and_States_with_PR/FeatureServer/0/query",
    "https://services.arcgis.com/cJ9YHowT8TU7DUyn/ArcGIS/rest/services/EJScreen_2_22_US_Percentiles_Tracts/FeatureServer/query")[1]
)

Arguments

countyfips

FIPS codes as 5-character strings (or numbers) in a vector as from fips_counties_from_state_abbrev("DE")

outFields

can be "*" for all, or can be just some variables like SQMI, POPULATION_2020, etc., or none

myservice

URL of feature service to get shapes from. Only default was tested

Value

spatial object via sf::st_read()

Details

Used sf::read_sf(), which is an alias for sf::st_read() but with some modified default arguments. read_sf is quiet by default/ does not print info about data source, and read_sf returns an sf-tibble rather than an sf-data.frame

Also note the tidycensus and tigris R packages.