-
Notifications
You must be signed in to change notification settings - Fork 1
/
jemez_hlsrbg_mar_05.R
34 lines (24 loc) · 1.02 KB
/
jemez_hlsrbg_mar_05.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
library(terra)
# RBG HLS imagery over the jemez for march 5th
# list list rgb bands from both days
setwd("/Users/jacktarricone/ch1_jemez_data/landsat_fsca/feb_18_tc/")
list <-list.files(pattern = "SR", full.names = TRUE) # list all files
print(list)
# full 12 band winter
hls_raw <-rast(list) # create "SpatRaster" for winter image
hls_raw # inspect
plot(hls_raw[[2]], col = gray(0:100 / 100)) # grayscale test plot
#bring in DEM
dem <-rast("/Users/jacktarricone/ch1_jemez_data/gpr_rasters_ryan/dem_feb12-19.tif")
dem
# resample, crop, and mask
hls_crop <-resample(hls, dem, method = "bilinear")
hls <-mask(hls_crop, dem, maskvalue = NA)
# test plot using terra's plotRGB function
plotRGB(hls, r = 4, g = 3, b = 2, stretch = "hist")
# create RGB 3 band rasters to save
mar_05_rgb <-c(hls[[4]], hls[[3]], hls[[2]])
# test plot these
plotRGB(mar_05_rgb, stretch = "lin")
plotRGB(mar_05_rgb, stretch = "hist", bgalpha = 0, add = TRUE)
writeRaster(mar_05_rgb, "/Users/jacktarricone/ch1_jemez_data/gpr_rasters_ryan/hls_rbg_mar05.tif")