# Setup for working example
library(coldpool)
library(akgfmaps)
reg_dat <- akgfmaps::get_base_layers(select.region = "ebs", set.crs = "EPSG:3338")
maxyr <- 2022
yrs <- (maxyr-19):maxyr
# CODE STARTS HERE #
# Names of EBS layers for years without NBS data
sebs_only <- names(coldpool::ebs_bottom_temperature)[which(!(names(coldpool::ebs_bottom_temperature) %in% paste0("s", names(coldpool::nbs_ebs_bottom_temperature))))]
# Select EBS years to include in rasterbrick and reproject EBS years to the extent and resolution of the EBS+NBS grid
sebs_temp <- raster::subset(coldpool::ebs_bottom_temperature,
subset = sebs_only) %>%
raster::projectRaster(coldpool::nbs_ebs_bottom_temperature)
# Combine EBS and NBS layers into the same rasterbrick
rasterbrick <- raster::addLayer(sebs_temp, coldpool::nbs_ebs_bottom_temperature)
# Remove non-numeric characters from layer names to simplify subsetting based on the year range
names(rasterbrick) <- gsub("[^0-9.-]", "", names(rasterbrick))
# Subset layers for the selected years
rasterbrick <- raster::subset(rasterbrick, subset = paste0("X", yrs))
Code for combining temperature from EBS-only years with temperature from EBS+NBS years in the same rasterbrick. Would slot-in around here: https://github.com/EmilyMarkowitz-NOAA/gap_bs_data_report/blob/861560b2bba6def981309652ba1c64c9a4effa35/code/figtab.Rmd#L579-L593
In the plotting function, remove NA values from the reprojected extent: https://github.com/EmilyMarkowitz-NOAA/gap_bs_data_report/blob/861560b2bba6def981309652ba1c64c9a4effa35/code/functions.R#L2372-L2375
with: