Description
When requesting 2024 PUMA geometries with cb = FALSE, tigris::pumas() constructs a TIGER URL using the directory TIGER2024/PUMA/, but the actual 2024 PUMA 2020-definition zips appear to be hosted under TIGER2024/PUMA20/. As a result, downloads fail with both HTTP and FTP fallback.
Reprex
library(tigris)
tigris::pumas(state = "Indiana", cb = FALSE, year = 2024)
Output:
• Using FIPS code 18 for Indiana
Downloading: 5.3 kB HTTP download failed, trying FTP as fallback...
trying URL 'ftp://ftp2.census.gov/geo/tiger/TIGER2024/PUMA/tl_2024_18_puma20.zip'
Warning message:
In download.file(ftp_url, destfile = file_loc, quiet = !progress_bar, :
cannot open URL 'ftp://ftp2.census.gov/geo/tiger/TIGER2024/PUMA/tl_2024_18_puma20.zip': FTP status was '550 Requested action not taken; file unavailable'
Error:
! Download failed with both HTTP and FTP; check your internet connection or the status of the Census Bureau website
at https://www2.census.gov/geo/tiger/ or ftp://ftp2.census.gov/geo/tiger/.
And for completeness, cb = TRUE behaves as documented:
tigris::pumas(state = "Indiana", cb = TRUE, year = 2024)
Errors with:
Cartographic boundary PUMAs are not yet available for years after 2020… (expected)
Expected behavior
For year = 2024 and cb = FALSE, pumas() should download tl_2024_18_puma20.zip and return the PUMA geometry for Indiana.
Evidence
The Census directory TIGER2024/PUMA20/ exists and contains tl_2024_18_puma20.zip (Indiana). Census
However, the current URL template for cb = FALSE uses .../TIGER%s/PUMA/tl_%s_%s_puma%s.zip:
|
"https://www2.census.gov/geo/tiger/TIGER%s/PUMA/tl_%s_%s_puma%s.zip", |
Proposed fix
Change URL construction for cb = FALSE to use PUMA20 when requesting puma20 files (i.e., year > 2021 / suf == "20"), e.g.:
- url <- sprintf("https://www2.census.gov/geo/tiger/TIGER%s/PUMA/tl_%s_%s_puma%s.zip",
- cyear, cyear, state, suf)
+ puma_dir <- if (year > 2021) "PUMA20" else "PUMA"
+ url <- sprintf("https://www2.census.gov/geo/tiger/TIGER%s/%s/tl_%s_%s_puma%s.zip",
+ cyear, puma_dir, cyear, state, suf)
Session info
R version 4.4.3 (2025-02-28 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 26200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8 LC_NUMERIC=C LC_TIME=English_United States.utf8
time zone: America/Chicago
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] vctrs_0.7.1 httr_1.4.7 cli_3.6.5 rlang_1.1.7 stringi_1.8.7 DBI_1.2.3 KernSmooth_2.23-26 generics_0.1.4 sf_1.0-24 tigris_2.2.1.9000 glue_1.8.0 e1071_1.7-17
[13] rappdirs_0.3.4 grid_4.4.3 classInt_0.4-11 tibble_3.3.1 lifecycle_1.0.5 stringr_1.6.0 compiler_4.4.3 dplyr_1.2.0 Rcpp_1.1.1 pkgconfig_2.0.3 R6_2.6.1 class_7.3-23
[25] tidyselect_1.2.1 curl_7.0.0 pillar_1.11.1 magrittr_2.0.4 uuid_1.2-2 tools_4.4.3 proxy_0.4-29 units_1.0-0
Description
When requesting 2024 PUMA geometries with
cb = FALSE,tigris::pumas()constructs a TIGER URL using the directoryTIGER2024/PUMA/, but the actual 2024 PUMA 2020-definition zips appear to be hosted underTIGER2024/PUMA20/. As a result, downloads fail with both HTTP and FTP fallback.Reprex
Output:
And for completeness,
cb = TRUEbehaves as documented:Errors with:
Expected behavior
For
year = 2024andcb = FALSE,pumas()should downloadtl_2024_18_puma20.zipand return the PUMA geometry for Indiana.Evidence
The Census directory
TIGER2024/PUMA20/exists and containstl_2024_18_puma20.zip(Indiana). CensusHowever, the current URL template for
cb = FALSEuses.../TIGER%s/PUMA/tl_%s_%s_puma%s.zip:tigris/R/pumas.R
Line 114 in 07e457d
Proposed fix
Change URL construction for
cb = FALSEto usePUMA20when requestingpuma20files (i.e.,year > 2021/suf == "20"), e.g.:Session info