hrecht / censusapi

R package to retrieve U.S. Census data and metadata via API
https://www.hrecht.com/censusapi/
169 stars 30 forks source link

Selecting Places within Counties within States #74

Closed ABSOD closed 3 years ago

ABSOD commented 3 years ago

I need to select places within selected counties in a specific state from the 5-year ACS. For example, f.places <- getCensus( name = "acs/acs5", vintage = 2019, vars = c("NAME", "B01001_001E"....) , region = "place:*", regionin = ????)

What I need to do is select all of the places within Garfield County (FIPS CODE = 045), Colorado (FIPS CODE = 08). Is there a way to specify this kind of nested region?

TIA

hrecht commented 3 years ago

Hi, this is not possible because places are not always nested within counties, so the Census Bureau doesn't provide this data. Some cities cross county borders.

You can see the options using the Census metadata, with geos <- listCensusMetadata(name = "acs/acs5", vintage = 2019, type = "geographies") in R or look at https://api.census.gov/data/2019/acs/acs5/geography.html.

You can get places by state and then later filter to the relevant ones.