-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculateGAMStressRanges.R
More file actions
38 lines (33 loc) · 2.04 KB
/
CalculateGAMStressRanges.R
File metadata and controls
38 lines (33 loc) · 2.04 KB
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
library(tidyverse)
library(sf)
library(stars)
# Warp to the right CRS
rastered_preds21abin[[1]] <- st_warp(rastered_preds21abin[[1]], crs = 32610)
rastered_preds21abin[[2]] <- st_warp(rastered_preds21abin[[2]], crs = 32610)
rastered_preds25abin[[1]] <- st_warp(rastered_preds25abin[[1]], crs = 32610)
rastered_preds25abin[[2]] <- st_warp(rastered_preds25abin[[2]], crs = 32610)
rastered_preds21NRabin[[1]] <- st_warp(rastered_preds21NRabin[[1]], crs = 32610)
rastered_preds21NRabin[[2]] <- st_warp(rastered_preds21NRabin[[2]], crs = 32610)
deltabuff <- st_transform(deltabuff, crs = 32610)
# Crop each dataset
Avg21 <- rastered_preds21abin[[1]] %>% sf::st_crop(deltabuff)
Anom21 <- rastered_preds21abin[[2]] %>% sf::st_crop(deltabuff)
Avg25 <- rastered_preds25abin[[1]] %>% sf::st_crop(deltabuff)
Anom25 <- rastered_preds25abin[[2]] %>% sf::st_crop(deltabuff)
NRAvg21 <- rastered_preds21NRabin[[1]] %>% sf::st_crop(deltabuff)
NRAnom21 <- rastered_preds21NRabin[[2]] %>% sf::st_crop(deltabuff)
save(Avg21, Anom21, Avg25, Anom25, NRAvg21, NRAnom21,raster25Diff_crop, raster21Diff_crop, raster21NRDiff_crop, file= "cropped_datasets.RData")
load("cropped_datasets.RData")
# Make dataframes
df_Avg21 <- Avg21 %>% as.data.frame %>% mutate(Model = "Avg21")
df_Anom21 <- Anom21 %>% as.data.frame %>% mutate(Model = "Anom21")
df_Avg25 <- Avg25 %>% as.data.frame %>% mutate(Model = "Avg25")
df_Anom25 <- Anom25 %>% as.data.frame %>% mutate(Model = "Anom25")
df_NRAvg21 <- NRAvg21 %>% as.data.frame %>% mutate(Model = "NRAvg21")
df_NRAnom21 <- NRAnom21 %>% as.data.frame %>% mutate(Model = "NRAnom21")
df_diff21 <- raster21Diff_crop %>% as.data.frame %>% mutate(Model = "Diff21")
df_diff25 <- raster25Diff_crop %>% as.data.frame %>% mutate(Model = "Diff25")
df_NRdiff21 <- raster21Diff_crop %>% as.data.frame %>% mutate(Model = "NRDiff21")
# Calculate ranges
All <- rbind(df_Avg21, df_Anom21, df_Avg25, df_Anom25, df_NRAvg21, df_NRAnom21, df_diff21, df_diff25, df_NRdiff21)
Ranges <- All %>% group_by(Model) %>% summarize(min = min(Prediction2, na.rm = TRUE), max = max(Prediction2, na.rm = TRUE))