Created
November 3, 2021 14:34
-
-
Save walkerke/c6331bff465a2abf5c3c25b3dbd45afd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidycensus) | |
library(tidyverse) | |
library(sf) | |
library(mapview) | |
library(crsuggest) | |
# Get data on median home value by block group in Fort Bend County | |
fort_bend_value <- get_acs( | |
geography = "block group", | |
variables = "B25077_001", | |
state = "TX", | |
county = "Fort Bend", | |
geometry = TRUE | |
) | |
# Get an appropriate CRS: NAD83 / TX South Central (32140) | |
fort_bend_crs <- suggest_top_crs(fort_bend_value, units = "m") | |
# Generate a 1km hexgrid over FB County | |
fort_bend_grid <- fort_bend_value %>% | |
st_transform(fort_bend_crs) %>% | |
st_make_grid(cellsize = 1000, square = FALSE) | |
# Use areal interpolation to transfer block group | |
# values to the grid | |
fort_bend_interpolated <- fort_bend_value %>% | |
st_transform(fort_bend_crs) %>% | |
select(estimate) %>% | |
na.omit() %>% | |
st_interpolate_aw( | |
to = fort_bend_grid, | |
extensive = FALSE | |
) | |
# Take a look at the results | |
mapview(fort_bend_interpolated, zcol = "estimate", | |
layer.name = "Median home value,<br/>2015-2019 ACS") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment