R/coastline.R

Defines functions tt_coastline

Documented in tt_coastline

#' Download TIGER shapes for Coastlines
#'
#' @templateVar year TRUE
#' @template template
#'
#' @return sf data.frame
#' @export
#'
#' @concept water
#'
#' @examples
#' \donttest{ # takes > 5 seconds
#' # Wrapped in try due to false positive 304 errors
#' \donttest{try(tt_coastline())} # downloads slow on CRAN
#' }
tt_coastline <- function(year = 2022) {

  years_okay(year, 2016:2022)

  zip_url <- glue::glue("{base_url(year)}/COASTLINE/tl_{year}_us_coastline.zip")
  target <- paste0("tl_", year, "_us_coastline.shp")
  shp <- tt_download_read(url = zip_url, target_file = target)

  adj_class(shp)
}

Try the tinytiger package in your browser

Any scripts or data that you put into this service are public.

tinytiger documentation built on Oct. 18, 2023, 1:11 a.m.