library(tigris
) co <- counties(cb = TRUE) %>%
shift_geometry()
Use the shift_geometry() function of tigris to shift and optionally rescale AK/HI/PR (relative to the continental US). Available arguments are preserve_area = (TRUE or FALSE) and position = ("below" or "outside"). FALSE and "below" are the defaults. Features in the continental United States will have their CRS transformed to USA Contiguous Albers Equal Area Conic (’ESRI:102003’). Alaska, Hawaii, and Puerto Rico features are transformed to appropriate coordinate systems for those areas, then shifted and optionally re-scaled before being assigned the ’ESRI:102003’ CRS.
Below example uses the get_acs() function in tidycensus. Gathers county geographies from NC, with Census variable B01003_001 as an attribute. Kyle Walker's basic usage page explains the geographies available and how to use the function load_variables() to search a list of available indicators.
Use the shift_geo = TRUE argument with any of the tidycensus "get_" functions to provide geometry with Alaska and Hawaii shifted for thematic mapping of the entire US. The geometry = TRUE argument returns an sf tibble with simple feature geometry in the ‘geometry‘ column.
nc_pop <-
get_acs(geography = "county",
variables = "B01003_001",
state = "NC",
geometry = TRUE,
shift_geo = TRUE)
library(devtools)
devtools::install_github(“UrbanInstitute/urbnmapr”)library(urbnmapr)