diff --git a/R/census.R b/R/census.R index ad4c430..339ac8e 100644 --- a/R/census.R +++ b/R/census.R @@ -435,8 +435,13 @@ get_decennial <- function(geography, } else { - geom <- try(suppressMessages(use_tigris(geography = geography, year = year, - state = state, county = county, ...))) + if (geography == "urban area" && year == 2020) { + geom <- try(suppressMessages(use_tigris(geography = geography, year = year, + state = state, county = county, criteria = "2020", ...))) + } else { + geom <- try(suppressMessages(use_tigris(geography = geography, year = year, + state = state, county = county, ...))) + } if ("try-error" %in% class(geom)) { stop("Your geometry data download failed. Please try again later or check the status of the Census Bureau website at https://www2.census.gov/geo/tiger/", call. = FALSE) diff --git a/R/helpers.R b/R/helpers.R index 5a1aa28..c3374e7 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -309,9 +309,18 @@ use_tigris <- function(geography, year, cb = TRUE, resolution = "500k", # Right now, urban areas are not defined for 2020 and are not in the CB file if (year == 2020) cb <- FALSE + # The 2020 decennial Census uses the 2020 urban areas, but the 2020 ACS + # does not, so we will need to figure that out in the get_decennial side + # Pass that through as a keyword argument + ua <- urban_areas(cb = cb, year = year, class = "sf", ...) - ua <- rename(ua, GEOID = GEOID10) + if ("GEOID20" %in% names(ua)) { + ua <- rename(ua, GEOID = GEOID20) + } else { + ua <- rename(ua, GEOID = GEOID10) + } + return(ua)