-
Notifications
You must be signed in to change notification settings - Fork 1
/
jemez_nlcd_cc_qaqc.R
50 lines (37 loc) · 1.16 KB
/
jemez_nlcd_cc_qaqc.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# save and crop the NLCD land cover and canopy cover data
# jan 27th, 2022
library(terra)
library(raster)
# set saving location
setwd("/Users/jacktarricone/ch1_jemez_data/gpr_rasters_ryan/")
#bring in DEM
dem <-rast("/Users/jacktarricone/ch1_jemez_data/gpr_rasters_ryan/dem_feb12-19.tif")
dem
# bring in raw nlcd 2026 cc data
cc_raw <-rast("/Users/jacktarricone/ch1_jemez_data/nlcd/NLCD_2016_Tree_Canopy_L48_20190831_Y6k85Ek4KV2m251VVyWr.tiff")
cc_raw
plot(cc_raw)
# landcover 2019
lc_raw <-rast("/Users/jacktarricone/ch1_jemez_data/nlcd/NLCD_2019_Land_Cover_L48_20210604_Y6k85Ek4KV2m251VVyWr.tiff")
lc_raw
plot(lc_raw)
#################
# resample, crop, and mask canopy cover
##############
cc_crop <-resample(cc_raw, dem, method = "bilinear")
cc <-mask(cc_crop, dem, maskvalue = NA)
# test plot
plot(dem)
plot(cc, add=TRUE)
# writeRaster(cc, "cc_percent.tif")
#################
# resample, crop, and mask canopy cover
##############
# used nearest neighbor for categorical data here
lc_crop <-resample(lc_raw, dem, method = "near")
plot(lc_crop)
lc <-mask(lc_crop, dem, maskvalue = NA)
# test plot
plot(dem)
plot(lc, add=TRUE)
# writeRaster(lc, "nlcd_land_cover.tif")