if (FALSE) {
library(sf)
# Use Costa Rica outline (included in paisaje)
aoi <- paisaje::cr_outline_c
# Single variable - Annual mean temperature, mid-century, pessimistic
bio1_fut <- get_chelsa_future(
var = "bio1",
scenario = "ssp585",
period = "2041-2070",
gcm = "MPI-ESM1-2-HR",
aoi = aoi
)
# Multiple variables - near future, optimistic
bio_stack <- get_chelsa_future(
var = c("bio1", "bio12", "bio15"),
scenario = "ssp126",
period = "2011-2040",
gcm = "GFDL-ESM4",
aoi = aoi
)
# Compare historic vs future bio1 for Costa Rica
bio1_hist <- get_chelsa_historic(var = "bio1", aoi = aoi)
bio1_diff <- bio1_fut - bio1_hist
terra::plot(bio1_diff, main = "Temperature change (bio1): 2041-2070 SSP585")
# Extract per H3 hexagon
h7 <- paisaje::get_h3_grid(aoi, res = 7)
h7_fut <- extract_num_raster(bio_stack, h7)
}
Run the code above in your browser using DataLab