New feature in tidycensus: migration flows data

We've added the ability to access county-to-county and MSA-to-MSA migration flows data via the tidycensus package in R. We've got code and map examples here: https://walker-data.com/tidycensus/articles/other-datasets.html#migration-flows-1. If you want to try it you, install the GitHub version of the package usingremotes::install_github("walkerke/tidycensus")

Here's how it works for getting the number of movers into Phoenix:

library(tidycensus)
library(dplyr)

phx_flows <- get_flows(
geography = "metropolitan statistical area",
msa = 38060,
geometry = TRUE
)

phx_flows %>%
filter(!is.na(GEOID2), variable == "MOVEDIN") %>%
head()
#> Simple feature collection with 6 features and 7 fields
#> Active geometry column: centroid1
#> Geometry type: POINT
#> Dimension: XY
#> Bounding box: xmin: -112.0705 ymin: 33.18571 xmax: -112.0705 ymax: 33.18571
#> Geodetic CRS: NAD83
#> # A tibble: 6 x 9
#> GEOID1 GEOID2 FULL1_NAME FULL2_NAME variable estimate moe
#> <chr> <chr> <chr> <chr> <chr> <dbl> <dbl>
#> 1 38060 10180 Phoenix-Mesa-Scotts~ Abilene, TX Metro ~ MOVEDIN 0 27
#> 2 38060 10380 Phoenix-Mesa-Scotts~ Aguadilla-Isabela,~ MOVEDIN 40 40
#> 3 38060 10420 Phoenix-Mesa-Scotts~ Akron, OH Metro Ar~ MOVEDIN 266 110
#> 4 38060 10540 Phoenix-Mesa-Scotts~ Albany, OR Metro A~ MOVEDIN 67 78
#> 5 38060 10580 Phoenix-Mesa-Scotts~ Albany-Schenectady~ MOVEDIN 99 71
#> 6 38060 10740 Phoenix-Mesa-Scotts~ Albuquerque, NM Me~ MOVEDIN 2441 604
#> # ... with 2 more variables: centroid1 <POINT [°]>, centroid2 <POINT [°]>

library(mapdeck)

top_move_in <- phx_flows %>%
filter(!is.na(GEOID2), variable == "MOVEDIN") %>%
slice_max(n = 25, order_by = estimate) %>%
mutate(width = estimate / 500)

top_move_in %>%
mapdeck(style = mapdeck_style("dark"), pitch = 45) %>%
add_arc(
origin = "centroid1",
destination = "centroid2",
stroke_width = "width"
)