diff --git a/data-raw/make_geo_sf.R b/data-raw/make_geo_sf.R index 749c0e4..bf65e2b 100644 --- a/data-raw/make_geo_sf.R +++ b/data-raw/make_geo_sf.R @@ -22,8 +22,8 @@ stamford_sf <- sf::st_read("https://gist.github.com/camille-s/7002148f77b0020f78 bridgeport_sf <- sf::st_read("https://gist.github.com/camille-s/c5e4f0178cfbf288af454016018f5173/raw/43faa412db577c4f770d861ab913116ccdb3d445/bpt_tract_neighborhoods.geojson") |> dplyr::select(name = Name, geometry) |> - sf::st_transform(sf::st_crs(tract_sf)) |> - sf::st_simplify(dTolerance = 1e-6) + sf::st_make_valid() |> + sf::st_transform(sf::st_crs(tract_sf)) hartford_sf <- sf::st_read("https://gist.github.com/camille-s/9e9761b69a7c86bf6d7163cb73636f26/raw/3858f538d955c022b43e168e4c7cec316c2e437f/hfd_shape.json") |> diff --git a/data-raw/make_laus_codes.R b/data-raw/make_laus_codes.R index fad8f8e..d0ceb62 100644 --- a/data-raw/make_laus_codes.R +++ b/data-raw/make_laus_codes.R @@ -6,13 +6,26 @@ # dplyr::select(type = area_type_code, area, code = area_code) # bls updated the measures listed--for now, filter to the original 4 -laus_measures <- readr::read_tsv("https://download.bls.gov/pub/time.series/la/la.measure") |> + +# no longer allows direct download--403 error +# got these headers from firefox devtools +headers <- list("User-Agent" = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0", + "Accept" = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8", + "Accept-Language" = "en-US,en;q=0.5", + "Accept-Encoding" = "gzip, deflate, br") +h1 <- curl::new_handle(); h2 <- curl::new_handle() +curl::handle_setheaders(h1, .list = headers) +curl::handle_setheaders(h2, .list = headers) + +laus_measures <- curl::curl("https://download.bls.gov/pub/time.series/la/la.measure", open = "rb", handle = h1) |> + readr::read_tsv() |> dplyr::filter(measure_code %in% c("03", "04", "05", "06")) # make this internal # usethis::use_data(laus_measures, overwrite = TRUE) -laus_codes <- readr::read_tsv("https://download.bls.gov/pub/time.series/la/la.area") |> +laus_codes <- curl::curl("https://download.bls.gov/pub/time.series/la/la.area", open = "rb", handle = h2) |> + readr::read_tsv() |> dplyr::mutate(state_code = substr(area_code, 3, 4)) |> dplyr::left_join(dplyr::distinct(tidycensus::fips_codes, state_code, state), by = "state_code") |> dplyr::filter(area_type_code %in% c("A", "F", "G", "H")) |> diff --git a/data-raw/make_neighborhood_weights.R b/data-raw/make_neighborhood_weights.R index dad2277..f783200 100644 --- a/data-raw/make_neighborhood_weights.R +++ b/data-raw/make_neighborhood_weights.R @@ -74,9 +74,9 @@ tract2nhood <- block2nhood |> dplyr::mutate(weight = round(hh / sum(hh), 3)) |> dplyr::ungroup() |> dplyr::select(-hh) |> - dplyr::left_join(dplyr::distinct(cwi::xwalk, tract, tract_cog_fips), by = "tract") |> + dplyr::left_join(dplyr::distinct(cwi::xwalk, tract, tract_cog), by = "tract") |> split(~city) |> - purrr::map(dplyr::select, town, name, geoid = tract, geoid_cog = tract_cog_fips, weight) |> + purrr::map(dplyr::select, town, name, geoid = tract, geoid_cog = tract_cog, weight) |> purrr::map(janitor::remove_empty, "cols") |> rlang::set_names(~paste(., "tracts", sep = "_")) diff --git a/data/bridgeport_sf.rda b/data/bridgeport_sf.rda index 6b67872..939ed7c 100644 Binary files a/data/bridgeport_sf.rda and b/data/bridgeport_sf.rda differ