Make WA_lc

Harold Nelson

11/12/2021

Make Land Cover for Washington State

Setup

library(raster)
library(tmap)
library(sf)
library(tidyverse)
load("counties_us.Rdata")

Get NLCD

nl = raster("nlcd_2019_land_cover_l48_20210604.img")
tm_shape(nl) + tm_raster()
## stars_proxy object shown at 1243 by 805 cells.
## Warning: Duplicated levels found. They have been omitted

Extract Washington State

WA = counties_us %>% filter(STATEFP ==53)
thecrs = crs(nl)
WA = st_transform(WA,thecrs)
WA_lc = crop(nl,WA)
## Warning in matrix(ratvalues, nrow = length(ratvalues)/length(ratnames)): data
## length [1791] is not a sub-multiple or multiple of the number of rows [255]
save(WA_lc,file = "WA_lc.Rdata")

Display

tm_shape(WA_lc) + 
  tm_raster() +
tm_shape(WA)  +
  tm_borders(col="blue",lwd=2)
## stars_proxy object shown at 1163 by 861 cells.

thurston = WA %>% filter(NAME == "Thurston")
th_crop = crop(WA_lc,thurston)

tm_shape(th_crop) + 
  tm_raster() +
tm_shape(thurston) +
  tm_borders(lwd = 2,col = "purple")
## stars object downsampled to 1077 by 929 cells. See tm_shape manual (argument raster.downsample)

save(th_crop,file = "th_crop.Rdata")