Skip to content

Commit

Permalink
get congressional districts for 2022 and 2023 working
Browse files Browse the repository at this point in the history
  • Loading branch information
walkerke committed Jan 23, 2024
1 parent f680a4e commit 9f2b55f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: tigris
Type: Package
Title: Load Census TIGER/Line Shapefiles
Version: 2.0.6
Date: 2024-01-19
Date: 2024-01-23
Authors@R: c(
person(given="Kyle", family="Walker", email="kyle@walker-data.com", role=c("aut", "cre")),
person(given="Bob", family="Rudis", email="bob@rudis.net", role="ctb")
Expand Down
11 changes: 7 additions & 4 deletions R/legislative.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,17 @@ congressional_districts <- function(state = NULL, cb = FALSE, resolution = '500k
if (year == 2013) url <- gsub("shp/", "", url)

} else {

if (year == 2023) {
# Have to handle 2022 and 2023 differently as national CD file is not available
if (year %in% 2022:2023) {
if (is.null(state)) {
state_codes <- c(state.abb, "DC", "PR")
state_codes <- unique(tigris::fips_codes$state_code)
state_codes <- state_codes[state_codes != "74"]
cds <- lapply(state_codes, function(x) {
tigris::congressional_districts(state = x)
suppressMessages(tigris::congressional_districts(state = x, year = year))
}) %>%
rbind_tigris()

return(cds)
} else {
url <- sprintf("https://www2.census.gov/geo/tiger/TIGER%s/CD/tl_%s_%s_cd%s.zip", cyear, cyear, validate_state(state), congress)
}
Expand Down

0 comments on commit 9f2b55f

Please sign in to comment.