Created
November 10, 2022 14:37
-
-
Save walkerke/a926b2762e410fc58767c4220ea4bfb2 to your computer and use it in GitHub Desktop.
This file contains 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(tidyterra) | |
library(tidyverse) | |
library(terra) | |
library(tigris) | |
library(sf) | |
library(mapboxapi) | |
# Get data from https://www.mrlc.gov/data/nlcd-2019-land-cover-conus | |
# Warning - it's big! | |
nlcd <- rast("~/data/nlcd_2019_land_cover_l48_20210604/nlcd_2019_land_cover_l48_20210604.img") | |
fw <- places("TX", cb = TRUE) %>% | |
filter(NAME == "Fort Worth") %>% | |
st_transform(st_crs(nlcd)) | |
fw_nlcd_open <- nlcd %>% | |
crop(fw) %>% | |
mask(fw) %>% | |
filter(`NLCD Land Cover Class` == "Developed, Open Space") | |
base_layer <- layer_static_mapbox( | |
location = fw, | |
style_id = "light-v10", | |
username = "mapbox" | |
) | |
ggplot() + | |
base_layer + | |
geom_spatraster(data = fw_nlcd_open) + | |
scale_fill_discrete(na.value = NA, type = "darkgreen", | |
guide = "none") + | |
geom_sf(data = fw, color = "black", fill = NA) + | |
theme_void() + | |
labs(title = "Developed, Open Space land use, 2019", | |
subtitle = "Fort Worth, Texas", | |
caption = "Data source: NLCD | @kyle_e_walker") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment