Yield change scenarios based on theoretical models
In this script, we visualize yield changes based on theoretical model provided by Agnolucci. We visualize scenarios for:
- wheat,
- barley,
- potatoes,
- oats,
- rapeseed.
Load packages, read data and source custom scripts
rm(list = ls())
library(stars)
#> Loading required package: abind
#> Loading required package: sf
#> Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
path_proj <- day2day::git_path()
path_data <- file.path(path_proj, "data")
path_cleaned <- file.path(path_data, "cleaned")
path_modelled <- file.path(path_data, "modelled")
source(file.path(path_proj, "src", "34-read-sce-var.R"))
source(file.path(path_proj, "src", "61-vis-stars.R"))
yields <- readRDS(file.path(path_cleaned, "yield-params-and-season.rds"))
uk <- st_read(file.path(path_cleaned, "uk_simple.gpkg"), "union")
#> Reading layer `union' from data source `/home/rstudio/Documents/Projects/land-suitability/data/cleaned/uk_simple.gpkg' using driver `GPKG'
#> Simple feature collection with 1 feature and 0 fields
#> geometry type: MULTIPOLYGON
#> dimension: XY
#> bbox: xmin: -116.1923 ymin: 7054.099 xmax: 655644.8 ymax: 1218625
#> projected CRS: OSGB 1936 / British National Grid
products <- names(yields$season)
Visualize
read_yield_change <- function(path_read, var = "wheat") {
pattern <- paste("uk_1km_yield_change", var, "20yr", sep = "_")
regex <- "^.+_20yr-[a-z]+-[a-z]+_([[:digit:]]{4}).+(-[[:digit:]]{4}).+$"
out <- read_sce_var(path_read, pattern, regex)
return(out)
}
for (product in products) {
cat(paste0("\n### Yield change scenarios (", product, ")\n" ))
out <- read_yield_change(path_modelled, product)
plot_stars(out, uk, nbreaks = 20, breaks = "quantile")
cat("\n")
}
Yield change scenarios (barley)
Yield change scenarios (oats)
Yield change scenarios (potatoes)
Yield change scenarios (rapeseed)
Yield change scenarios (wheat)
Time to execute the task
Only useful when executed with Rscript
.
proc.time()
#> user system elapsed
#> 76.523 4.855 81.449