walkerke / tidycensus

Load US Census boundary and attribute data as 'tidyverse' and 'sf'-ready data frames in R
https://walker-data.com/tidycensus
Other
639 stars 100 forks source link

Error: Cannot open layer cb_2019_54_bg_500k #370

Closed CharlotteLooby closed 3 years ago

CharlotteLooby commented 3 years ago

I'm getting an error when submitting this code:

CBG_all <- get_acs(state = "WV", geography = "block group", variables = "B19301_001", geometry = TRUE) %>% st_transform(crs = "+init=epsg:4326")

Here's the error:

Getting data from the 2015-2019 5-year ACS Downloading feature geometry from the Census website. To cache shapefiles for use in future sessions, set options(tigris_use_cache = TRUE). Fetching block group data by county and combining the result. Cannot open layer cb_2019_54_bg_500k Cannot open layer cb_2019_54_bg_500k Cannot open layer cb_2019_54_bg_500k Error: Request failed after 3 attempts Run rlang::last_error() to see where the error occurred. In addition: Warning messages: 1: In unzip(file_loc, exdir = tmp) : error 1 in extracting from zip file 2: In unzip(file_loc, exdir = tmp) : error 1 in extracting from zip file 3: In unzip(file_loc, exdir = tmp) : error 1 in extracting from zip file

I get the same error when running for 2017 and 2018. When I run the code above for DE, it works. Do you know what could be going on?

Thanks for your help!

mfherman commented 3 years ago

Hi @CharlotteLooby -- this is the type of error message that is returned when there are issues with the Census FTP site that hosts these shapefiles. I just tested your code now and it is working for me. Another options is to set options(tigris_use_cache = TRUE) so you don't have to re-download after you've downloaded successfully the first time.

@walkerke I wonder if there is a more graceful error message we can display on this type of failure? If I have some time, I can poke around tigris and see how to implement that.

walkerke commented 3 years ago

@mfherman yeah, there certainly is. Honestly a lot of that code on the tigris side hasn't been updated in a while, we should probably add some sort of check that the HTTP request was successful and give an informative error message if it isn't like we do on the tidycensus side.