Closed anna-nguyen closed 3 years ago
Thanks for the heads up! Looks like Census just changed the API to require a state when requesting ZCTAs by ZCTA. We'll push a fix soon. In the meantime, a workaround that runs quickly:
library(tidycensus)
library(tidyverse)
get_acs(geography = "zcta",
variables = "C16001_001",
state = "CA") %>%
filter(GEOID == "90210")
Getting data from the 2015-2019 5-year ACS
Using FIPS code '06' for state 'CA'
# A tibble: 1 x 5
GEOID NAME variable estimate moe
<chr> <chr> <chr> <dbl> <dbl>
1 90210 ZCTA5 90210 C16001_001 18656 1010
Thanks! For my particular use case, I'm pulling data for ZCTAs that span a number of different states. It would be great to make it so multiple ZCTA/state pairs could be passed through as an argument!
This is now fixed in the master branch:
library(tidycensus)
get_acs(
geography = "zcta",
variables = "C16001_001",
state = "CA",
zcta = 90210
)
Getting data from the 2015-2019 5-year ACS
Using FIPS code '06' for state 'CA'
# A tibble: 1 x 5
GEOID NAME variable estimate moe
<chr> <chr> <chr> <dbl> <dbl>
1 90210 ZCTA5 90210 C16001_001 18656 1010
You can also request multiple states & multiple ZCTAs:
get_acs(
geography = "zcta",
variables = "C16001_001",
state = c("CA", "TX"),
zcta = c(90210, 76109)
)
Getting data from the 2015-2019 5-year ACS
Using FIPS code '06' for state 'CA'
Using FIPS code '48' for state 'TX'
# A tibble: 2 x 5
GEOID NAME variable estimate moe
<chr> <chr> <chr> <dbl> <dbl>
1 90210 ZCTA5 90210 C16001_001 18656 1010
2 76109 ZCTA5 76109 C16001_001 21808 1108
Hi,
I am running into this issue only with both 2016-2020 and 2017-2021 5-year ACS. Is this coming from the Census API? do you have a suggested solution for this? Thank you!
@sisiraul As of the 2020 ACS, subsetting by state is no longer supported for ZCTAs on the API side, unfortunately. You could grab a state boundary with tigris and then use that as a filter_by
argument in tidycensus; I'll write up an example when I have a minute.
@walkerke did you ever have a chance to write up that example?
@sisiraul As of the 2020 ACS, subsetting by state is no longer supported for ZCTAs on the API side, unfortunately. You could grab a state boundary with tigris and then use that as a
filter_by
argument in tidycensus; I'll write up an example when I have a minute.
I am wondering why
tidycensus::get_acs(geography = "zcta")
we can specify state
if year
is between 2011 and 2019...tigris::zctas()
does not allow setting the state
parameter unless year
is set to 2000 or 2010Are the ZCTA geometry
data returned by these two functions different for a given year
?
I'm not sure if this is a tidycensus
or tigris
question, so sorry if this is misplaced.
Hello!
I'm using
get_acs
to pull ZCTA level characteristics. I want to subset to specific ZCTAs using thezcta
option, but run into the following error:When I try to qualify the ZCTA with a state by setting
state = "CA"
, data for all ZIP codes in California is returned.This seems to be an issue with the Census API itself (I've tried running various API calls directly with no luck :( ), but please let me know if there's a workaround that I might have missed!