Skip to content

Commit

Permalink
batch of updates / fix #180
Browse files Browse the repository at this point in the history
  • Loading branch information
walkerke committed Jan 20, 2024
1 parent 0cc826a commit f680a4e
Show file tree
Hide file tree
Showing 49 changed files with 99 additions and 86 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: tigris
Type: Package
Title: Load Census TIGER/Line Shapefiles
Version: 2.0.4
Date: 2023-09-21
Version: 2.0.6
Date: 2024-01-19
Authors@R: c(
person(given="Kyle", family="Walker", email="[email protected]", role=c("aut", "cre")),
person(given="Bob", family="Rudis", email="[email protected]", role="ctb")
Expand Down
14 changes: 7 additions & 7 deletions R/enumeration_units.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ counties <- function(state = NULL, cb = FALSE, resolution = '500k', year = NULL,

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down Expand Up @@ -239,7 +239,7 @@ tracts <- function(state = NULL, county = NULL, cb = FALSE, resolution = "500k",

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down Expand Up @@ -424,7 +424,7 @@ school_districts <- function(state = NULL, type = 'unified',

if (is.null(year)) {

year = getOption("tigris_year", 2021)
year = getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down Expand Up @@ -532,7 +532,7 @@ block_groups <- function(state = NULL, county = NULL, cb = FALSE, year = NULL, .

if (is.null(year)) {

year = getOption("tigris_year", 2021)
year = getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down Expand Up @@ -711,7 +711,7 @@ zctas <- function(cb = FALSE, starts_with = NULL, year = NULL, state = NULL, ...

if (is.null(year)) {

year = getOption("tigris_year", 2021)
year = getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down Expand Up @@ -869,7 +869,7 @@ blocks <- function(state, county = NULL, year = NULL, ...) {

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down Expand Up @@ -996,7 +996,7 @@ county_subdivisions <- function(state, county = NULL, cb = FALSE, year = NULL, .

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down
4 changes: 2 additions & 2 deletions R/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ erase_water <- function(input_sf,
}

if (is.null(year)) {
year <- getOption("tigris_year", 2020)
year <- getOption("tigris_year", 2022)
}

# Define st_erase function internally
Expand Down Expand Up @@ -704,7 +704,7 @@ erase_water <- function(input_sf,
#' `@inheritSection load_tiger_doc_template Additional Arguments`
#'
#' @param ... arguments to be passed to internal function `load_tiger`, which is not exported. See Additional Arguments.
#' @param year the data year; defaults to 2021
#' @param year the data year; defaults to 2022
#'
#' @section Additional Arguments:
#' Additional arguments that can be passed in `...` are:
Expand Down
4 changes: 2 additions & 2 deletions R/landmarks.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ military <- function(year = NULL, ...) {

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down Expand Up @@ -79,7 +79,7 @@ landmarks <- function(state, type = "point", year = NULL, ...) {

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down
35 changes: 24 additions & 11 deletions R/legislative.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#'
#' Congressional districts for the 108th through 112th sessions were established by the states based on the result of the 2000 Census. Congressional districts for the 113th through 116th sessions were established by the states based on the result of the 2010 Census. Boundaries are effective until January of odd number years (for example, January 2015, January 2017, etc.), unless a state initiative or court ordered redistricting requires a change. All states established new congressional districts in 2011-2012, with the exception of the seven single member states (Alaska, Delaware, Montana, North Dakota, South Dakota, Vermont, and Wyoming).
#'
#' The current default in tigris reflects boundaries for the 116th Congress, which is available as of February 2021 for years 2018 through 2021. Older congressional district boundaries back to 2011 can be obtained by supplying the appropriate year.
#' The current default in tigris reflects boundaries for the 118th Congress, which is available for years 2022 and 2023. Older congressional district boundaries back to 2011 can be obtained by supplying the appropriate year.
#'
#' @param state The two-digit FIPS code (string) of the state you want, or a
#' vector of codes if you want multiple states. Can also be state name
Expand All @@ -24,28 +24,28 @@
#' library(tigris)
#' library(leaflet)
#'
#' cd116 <- congressional_districts(cb = TRUE, resolution = '20m')
#' cd118 <- congressional_districts(cb = TRUE, resolution = '20m', year = 2022)
#'
#' leaflet(cd116) %>%
#' leaflet(cd118) %>%
#' addTiles() %>%
#' addPolygons()
#' }
congressional_districts <- function(state = NULL, cb = FALSE, resolution = '500k', year = NULL, ...) {

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

}

if (year < 2013 && cb == TRUE) {
if (year < 2013 && cb) {
stop("`cb = TRUE` for congressional districts is unavailable prior to 2013. Regular TIGER/Line files are available for 2010 through 2010 with `cb = FALSE`",
call. = FALSE)
}

if (year %in% 2018:2022) {
if (year %in% 2018:2021) {
congress <- "116"
} else if (year %in% 2016:2017) {
congress <- "115"
Expand All @@ -57,6 +57,8 @@ congressional_districts <- function(state = NULL, cb = FALSE, resolution = '500k
congress <- "112"
} else if (year == 2010) {
congress <- "111"
} else if (year %in% 2022:2023) {
congress <- "118"
}

if (year < 2010) {
Expand All @@ -75,7 +77,7 @@ congressional_districts <- function(state = NULL, cb = FALSE, resolution = '500k

cyear <- as.character(year)

if (cb == TRUE) {
if (cb) {

url <- sprintf("https://www2.census.gov/geo/tiger/GENZ%s/shp/cb_%s_us_cd%s_%s.zip",
cyear, cyear, congress, resolution)
Expand All @@ -84,9 +86,20 @@ congressional_districts <- function(state = NULL, cb = FALSE, resolution = '500k

} else {

url <- sprintf("https://www2.census.gov/geo/tiger/TIGER%s/CD/tl_%s_us_cd%s.zip",
cyear, cyear, congress)

if (year == 2023) {
if (is.null(state)) {
state_codes <- c(state.abb, "DC", "PR")
cds <- lapply(state_codes, function(x) {
tigris::congressional_districts(state = x)
}) %>%
rbind_tigris()
} else {
url <- sprintf("https://www2.census.gov/geo/tiger/TIGER%s/CD/tl_%s_%s_cd%s.zip", cyear, cyear, validate_state(state), congress)
}
} else {
url <- sprintf("https://www2.census.gov/geo/tiger/TIGER%s/CD/tl_%s_us_cd%s.zip",
cyear, cyear, congress)
}
}

cds <- load_tiger(url, tigris_type="congressional_districts", ...)
Expand Down Expand Up @@ -141,7 +154,7 @@ state_legislative_districts <- function(state= NULL, house = "upper",

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down
10 changes: 5 additions & 5 deletions R/metro_areas.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ core_based_statistical_areas <- function(cb = FALSE, resolution = '500k', year =

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down Expand Up @@ -93,7 +93,7 @@ urban_areas <- function(cb = FALSE, year = NULL, criteria = NULL, ...) {

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down Expand Up @@ -165,7 +165,7 @@ combined_statistical_areas <- function(cb = FALSE, resolution = '500k', year = N

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down Expand Up @@ -217,7 +217,7 @@ metro_divisions <- function(year = NULL, ...) {

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down Expand Up @@ -278,7 +278,7 @@ new_england <- function(type = 'necta', cb = FALSE, year = NULL, ...) {

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down
6 changes: 3 additions & 3 deletions R/national.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ regions <- function(resolution = '500k', year = NULL, ...) {

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down Expand Up @@ -76,7 +76,7 @@ divisions <- function(resolution = '500k', year = NULL, ...) {

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down Expand Up @@ -130,7 +130,7 @@ nation <- function(resolution = '5m', year = NULL, ...) {

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down
10 changes: 5 additions & 5 deletions R/native.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ native_areas <- function(cb = FALSE, year = NULL, ...) {

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down Expand Up @@ -95,7 +95,7 @@ tribal_subdivisions_national <- function(cb = FALSE, year = NULL, ...) {

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down Expand Up @@ -150,7 +150,7 @@ alaska_native_regional_corporations <- function(cb = FALSE, year = NULL, ...) {

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down Expand Up @@ -224,7 +224,7 @@ tribal_block_groups <- function(cb = FALSE, year = NULL, ...) {

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down Expand Up @@ -288,7 +288,7 @@ tribal_census_tracts <- function(cb = FALSE, year = NULL, ...) {

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down
2 changes: 1 addition & 1 deletion R/places.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ places <- function(state = NULL, cb = FALSE, year = NULL, ...) {

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down
2 changes: 1 addition & 1 deletion R/pumas.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pumas <- function(state = NULL, cb = FALSE, year = NULL, ...) {

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down
10 changes: 5 additions & 5 deletions R/transportation.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ roads <- function(state, county, year = NULL, ...) {

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

}

Expand Down Expand Up @@ -109,7 +109,7 @@ primary_roads <- function(year = NULL, ...) {

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down Expand Up @@ -165,7 +165,7 @@ primary_secondary_roads <- function(state, year = NULL, ...) {

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down Expand Up @@ -215,7 +215,7 @@ rails <- function(year = NULL, ...) {

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down Expand Up @@ -256,7 +256,7 @@ address_ranges <- function(state, county, year = NULL, ...) {

if (is.null(year)) {

year <- getOption("tigris_year", 2021)
year <- getOption("tigris_year", 2022)

message(sprintf("Retrieving data for the year %s", year))

Expand Down
Loading

0 comments on commit f680a4e

Please sign in to comment.