You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.5 KiB

  1. #' Retrieve CDC U.S. Basemaps
  2. #'
  3. #' The CDC FluView application uses a composite basemaps of coverage areas
  4. #' within the United States that elides and scales Alaska, Hawaii,
  5. #' Puerto Rico & the Virgin Islands and some further provide elided and scaled
  6. #' breakouts for New York City and the District of Columbia.\cr
  7. #' \cr
  8. #' This function retrieves the given shapefile, projects to EPSG:5069 and
  9. #' returns it as an `sf` (simple features) object.
  10. #'
  11. #' @md
  12. #' @export
  13. #' @param basemap select the CDC basemap. One of:
  14. #' - "`national`": outline of the U.S. + AK, HI, PR + VI
  15. #' - "`hhs`": outline of the U.S. + HHS Region Outlines + AK, HI, PR + VI
  16. #' - "`census`": outline of the U.S. + Census Region Outlines + AK, HI, PR + VI
  17. #' - "`states`": outline of the U.S. + State Outlines + AK, HI, PR + VI
  18. #' - "`spread`": outline of the U.S. + State Outlines + AK, HI, PR + VI & Guam
  19. #' - "`surv`": outline of the U.S. + State Outlines + AK, HI, PR + VI
  20. #' @note These are just the basemaps. You need to pair it with the data you wish to visualize.
  21. #' @examples \dontrun{
  22. #' plot(cdc_basemap("national"))
  23. #' }
  24. cdc_basemap <- function(basemap = c("national", "hhs", "census", "states", "spread", "surv")) {
  25. switch(
  26. basemap,
  27. national = .national_outline,
  28. hhs = .hhs_subregions_basemap,
  29. census = .census_divisions_basemap,
  30. states = .states_basemap,
  31. spread = .spread_basemap,
  32. surv = .surv_basemap
  33. ) -> selected_map
  34. xsf <- sf::st_read(selected_map, quiet=TRUE, stringsAsFactors=FALSE)
  35. sf::st_crs(xsf) <- 4326
  36. sf::st_transform(xsf, 5069)
  37. }