Skip to contents

Overview

In the last few vignettes, I have created various outputs that help me to analyze the risk of SLF establishment at for global viticultural regions. I created risk maps and tables, range shift maps and tables, risk quadrant maps for viticultural regions and SLF populations, and have calculated various summary statistics such as omission and commission error, area under the curve, and the optimal suitability threshold for each model.

In this vignette, I will use my function create_risk_report() to refine each of these outputs (excluding the summary statistics, which area model-specific) for countries and provinces of key importance for global viticulture. These outputs will crop maps and viticultural region risk assessments for each region of interest. I will begin by creating a report for each country in our input the wineries_tidied dataset. I will also create reports for key areas where viticulture is expected to expand or decline under climate change. This vignette will also outline the best practice for usage of my function create_risk_report().

Setup

# general tools
library(tidyverse)
library(cli)
library(here)
library(common)

# spatial data
library(terra)
library(sf)
library(rnaturalearth)
# remotes::install_github("ropensci/rnaturalearthhires")
library(rnaturalearthhires)
# remotes::install_github("ropensci/rnaturalearthdata")
library(rnaturalearthdata)

# aesthetics
library(kableExtra)
library(formattable)
library(webshot)
library(webshot2)
# devtools::install_github("eliocamp/ggnewscale", version = "0.4.10")
library(ggnewscale) ## MUST use version 0.4.10- 0.5.0 has a bug that breaks this function


# for analysis
library(patchwork)
#install.packages("gginnards")
library(gginnards)

Note: I will be setting the global options of this document so that only certain code chunks are rendered in the final .html file. I will set the eval = FALSE so that none of the code is re-run (preventing files from being overwritten during knitting) and will simply overwrite this in chunks with plots.

Create internal dataset for function

I will start by creating an internal dataset to be used by the function. These datasets were created in the previous vignettes and are stored in the data or data-raw folders of the package. I will import these datasets and save them as internal datasets for the function to use.

# .csv files
threshold_exponential_values <- read.csv(file = file.path(here::here(), "data-raw", "threshold_exponential_values.csv"))
# .rds files
IVR_locations <- readr::read_rds(file = file.path(here::here(), "data", "wineries_tidied.rds"))
summary_global <- readr::read_rds(file = file.path(here::here(), "data", "global_threshold_values.rds"))
summary_regional_ensemble <- readr::read_rds(file = file.path(here::here(), "data", "ensemble_threshold_values.rds"))
# predicted xy suitability
xy_global_1995 <- readr::read_rds(file = file.path(here::here(), "data", "global_wineries_1981-2010_xy_pred_suit.rds"))
xy_global_2055 <- readr::read_rds(file = file.path(here::here(), "data", "global_wineries_2041-2070_GFDL_ssp_mean_xy_pred_suit.rds"))
xy_regional_ensemble_1995 <- readr::read_rds(file = file.path(here::here(), "data", "regional_ensemble_wineries_1981-2010_xy_pred_suit.rds"))
xy_regional_ensemble_2055 <- readr::read_rds(file = file.path(here::here(), "data", "regional_ensemble_wineries_2041-2070_GFDL_ssp_mean_xy_pred_suit.rds"))
# transform all data frames to internal dataset
usethis::use_data(
  threshold_exponential_values, IVR_locations, summary_global, summary_regional_ensemble, xy_global_1995, xy_global_2055, xy_regional_ensemble_1995, xy_regional_ensemble_2055,
  internal = TRUE,
  overwrite = FALSE
)

Apply function

loop to apply function to wineries dataset

Primarily, I would like to use the wineries dataset to create a report for each unique country on the list. Our winery records contain 64 unique countries that I will create reports for. These reports will be saved to vignette-outputs/reports.

# import wineries dataset
IVR_locations <- readr::read_rds(file = file.path(here::here(), "data", "wineries_tidied.rds"))


n_distinct(IVR_locations$Country)
## [1] 64
# there are 64 unique countries on the list

# get iso codes using rnaturalearth data
admin_0_countries <- read_sf(dsn = file.path(here::here(), "data-raw", "ne_countries", "ne_10m_admin_0_countries.shp")) %>%
  dplyr::select(ADMIN, ADM0_A3)

# replace names in sf
admin_0_countries$ADMIN <- stringr::str_replace_all(admin_0_countries$ADMIN, "United States of America", "United States")
admin_0_countries$ADMIN <- stringr::str_replace_all(admin_0_countries$ADMIN, "South Korea", "Republic of Korea")
admin_0_countries$ADMIN <- stringr::str_replace_all(admin_0_countries$ADMIN, "Palestine", "Palestinian territories")
admin_0_countries$ADMIN <- stringr::str_replace_all(admin_0_countries$ADMIN, "Cabo Verde", "Cape Verde")
admin_0_countries$ADMIN <- stringr::str_replace_all(admin_0_countries$ADMIN, "Czechia", "Czech Republic")
admin_0_countries$ADMIN <- stringr::str_replace_all(admin_0_countries$ADMIN, "Republic of Serbia", "Serbia")

# correct misspelling
IVR_locations$Country <- stringr::str_replace_all(IVR_locations$Country, "Algiera", "Algeria")

# join
IVR_locations_iso <- left_join(IVR_locations, admin_0_countries, join_by(Country == ADMIN)) %>%
  dplyr::rename("iso_a3" = "ADM0_A3")
  
  
# check 
n_distinct(IVR_locations_iso$iso_a3)
## [1] 64
# it was successful, 64 unique iso codes

# sort dataset
unique_iso <- sort(unique(IVR_locations_iso$iso_a3))
# paired country names
unique_name <- IVR_locations_iso %>%
  group_by(iso_a3) %>%
  summarize(country = unique(Country)) %>%
  dplyr::select(country) %>%
  as.matrix() %>%
  as.character()

unique_name
##  [1] "Albania"                 "Argentina"              
##  [3] "Armenia"                 "Australia"              
##  [5] "Austria"                 "Azerbaijan"             
##  [7] "Belgium"                 "Bulgaria"               
##  [9] "Bosnia and Herzegovina"  "Bolivia"                
## [11] "Brazil"                  "Canada"                 
## [13] "Switzerland"             "Chile"                  
## [15] "China"                   "Cape Verde"             
## [17] "Cyprus"                  "Czech Republic"         
## [19] "Germany"                 "Algeria"                
## [21] "Spain"                   "France"                 
## [23] "Georgia"                 "Greece"                 
## [25] "Croatia"                 "Hungary"                
## [27] "Indonesia"               "India"                  
## [29] "Ireland"                 "Iran"                   
## [31] "Israel"                  "Italy"                  
## [33] "Japan"                   "Republic of Korea"      
## [35] "Lebanon"                 "Lithuania"              
## [37] "Luxembourg"              "Latvia"                 
## [39] "Morocco"                 "Moldova"                
## [41] "Mexico"                  "North Macedonia"        
## [43] "Myanmar"                 "Montenegro"             
## [45] "Netherlands"             "New Zealand"            
## [47] "Peru"                    "Poland"                 
## [49] "Portugal"                "Palestinian territories"
## [51] "Romania"                 "Russia"                 
## [53] "Serbia"                  "Slovakia"               
## [55] "Slovenia"                "Sweden"                 
## [57] "Syria"                   "Tunisia"                
## [59] "Turkey"                  "Ukraine"                
## [61] "United States"           "Venezuela"              
## [63] "Vietnam"                 "South Africa"
unique_iso
##  [1] "ALB" "ARG" "ARM" "AUS" "AUT" "AZE" "BEL" "BGR" "BIH" "BOL" "BRA" "CAN"
## [13] "CHE" "CHL" "CHN" "CPV" "CYP" "CZE" "DEU" "DZA" "ESP" "FRA" "GEO" "GRC"
## [25] "HRV" "HUN" "IDN" "IND" "IRL" "IRN" "ISR" "ITA" "JPN" "KOR" "LBN" "LTU"
## [37] "LUX" "LVA" "MAR" "MDA" "MEX" "MKD" "MMR" "MNE" "NLD" "NZL" "PER" "POL"
## [49] "PRT" "PSX" "ROU" "RUS" "SRB" "SVK" "SVN" "SWE" "SYR" "TUN" "TUR" "UKR"
## [61] "USA" "VEN" "VNM" "ZAF"
for (i in seq_along(unique_iso)){
  print(c(unique_name[i],unique_iso[i]))
}
## [1] "Albania" "ALB"    
## [1] "Argentina" "ARG"      
## [1] "Armenia" "ARM"    
## [1] "Australia" "AUS"      
## [1] "Austria" "AUT"    
## [1] "Azerbaijan" "AZE"       
## [1] "Belgium" "BEL"    
## [1] "Bulgaria" "BGR"     
## [1] "Bosnia and Herzegovina" "BIH"                   
## [1] "Bolivia" "BOL"    
## [1] "Brazil" "BRA"   
## [1] "Canada" "CAN"   
## [1] "Switzerland" "CHE"        
## [1] "Chile" "CHL"  
## [1] "China" "CHN"  
## [1] "Cape Verde" "CPV"       
## [1] "Cyprus" "CYP"   
## [1] "Czech Republic" "CZE"           
## [1] "Germany" "DEU"    
## [1] "Algeria" "DZA"    
## [1] "Spain" "ESP"  
## [1] "France" "FRA"   
## [1] "Georgia" "GEO"    
## [1] "Greece" "GRC"   
## [1] "Croatia" "HRV"    
## [1] "Hungary" "HUN"    
## [1] "Indonesia" "IDN"      
## [1] "India" "IND"  
## [1] "Ireland" "IRL"    
## [1] "Iran" "IRN" 
## [1] "Israel" "ISR"   
## [1] "Italy" "ITA"  
## [1] "Japan" "JPN"  
## [1] "Republic of Korea" "KOR"              
## [1] "Lebanon" "LBN"    
## [1] "Lithuania" "LTU"      
## [1] "Luxembourg" "LUX"       
## [1] "Latvia" "LVA"   
## [1] "Morocco" "MAR"    
## [1] "Moldova" "MDA"    
## [1] "Mexico" "MEX"   
## [1] "North Macedonia" "MKD"            
## [1] "Myanmar" "MMR"    
## [1] "Montenegro" "MNE"       
## [1] "Netherlands" "NLD"        
## [1] "New Zealand" "NZL"        
## [1] "Peru" "PER" 
## [1] "Poland" "POL"   
## [1] "Portugal" "PRT"     
## [1] "Palestinian territories" "PSX"                    
## [1] "Romania" "ROU"    
## [1] "Russia" "RUS"   
## [1] "Serbia" "SRB"   
## [1] "Slovakia" "SVK"     
## [1] "Slovenia" "SVN"     
## [1] "Sweden" "SWE"   
## [1] "Syria" "SYR"  
## [1] "Tunisia" "TUN"    
## [1] "Turkey" "TUR"   
## [1] "Ukraine" "UKR"    
## [1] "United States" "USA"          
## [1] "Venezuela" "VEN"      
## [1] "Vietnam" "VNM"    
## [1] "South Africa" "ZAF"
# loop thru country iso codes and names together
for (a in seq_along(unique_iso)) {
  
  scari::create_risk_report(
    locality.iso = unique_iso[a], # iso codes
    locality.name = unique_name[a], # names
    locality.type = "country",
    mypath = file.path(here::here(), "vignette-outputs", "reports", unique_name[a]),
    create.dir = TRUE, # create subdirectory for plots
    save.report = FALSE,
    buffer.dist = 20000 # distance at which buffers should be drawn on maps to indicate IVR suitability predictions
    )
  
}

Some of these maps might need to be edited to zoom in on the countries, because some countries have geographically separated territories that are not relevant to the analysis. The code to zoom in on those plots will be in the following section.

Generate Individual country and state/province reports

Alternatively, I will create individualized reports and maps for key viticultural areas of interest. I will group these regions by expected gain or loss in viticultural risk, and by geography. I will start out with the USA and China because they each contain so many SLF records and because I want to create reports for specific provinces within these countries.

USA

scari::create_risk_report(
  locality.iso = "usa",
  locality.name = "united states",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "United States"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)
##  proceeding without creating report output subdirectory folder
## Reading layer `ne_10m_admin_0_countries' from data source 
##   `C:\Users\tun83449\OneDrive - Temple University\Shared drives\slfClimate\projects\scari\scari\data-raw\ne_countries\ne_10m_admin_0_countries.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 258 features and 168 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -180 ymin: -90 xmax: 180 ymax: 83.6341
## Geodetic CRS:  WGS 84
##  Importing shapefiles from: C:/Users/tun83449/OneDrive - Temple University/Shared drives/slfClimate/projects/scari/scari/data-raw
## Reading layer `ne_10m_admin_1_states_provinces' from data source 
##   `C:\Users\tun83449\OneDrive - Temple University\Shared drives\slfClimate\projects\scari\scari\data-raw\ne_states_provinces\ne_10m_admin_1_states_provinces.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 4596 features and 121 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -180 ymin: -90 xmax: 180 ymax: 83.6341
## Geodetic CRS:  WGS 84
##  Data exist for locality
##  Suitability prediction type for IVR regions: buffer of 20000m around points
##  Risk maps plotted
##  Range shift map plotted
## Warning in stri_detect_regex(string, pattern, negate = negate, opts_regex =
## opts(pattern)): argument is not an atomic vector; coercing
##  Viticultural risk plot created
##  Viticultural regions list created
##  Risk map proportional areas table created
##  Range shift area table created
##  Viticultural risk table created
##  Report created
##  Report NOT saved to file
# try state level
scari::create_risk_report(
  locality.iso = "usa",
  locality.name = "california",
  locality.type = "state_province",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "United States"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)
##  proceeding without creating report output subdirectory folder
## Reading layer `ne_10m_admin_0_countries' from data source 
##   `C:\Users\tun83449\OneDrive - Temple University\Shared drives\slfClimate\projects\scari\scari\data-raw\ne_countries\ne_10m_admin_0_countries.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 258 features and 168 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -180 ymin: -90 xmax: 180 ymax: 83.6341
## Geodetic CRS:  WGS 84
##  Importing shapefiles from: C:/Users/tun83449/OneDrive - Temple University/Shared drives/slfClimate/projects/scari/scari/data-raw
## Reading layer `ne_10m_admin_1_states_provinces' from data source 
##   `C:\Users\tun83449\OneDrive - Temple University\Shared drives\slfClimate\projects\scari\scari\data-raw\ne_states_provinces\ne_10m_admin_1_states_provinces.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 4596 features and 121 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -180 ymin: -90 xmax: 180 ymax: 83.6341
## Geodetic CRS:  WGS 84
##  Data exist for locality
##  Suitability prediction type for IVR regions: buffer of 20000m around points
##  Risk maps plotted
##  Range shift map plotted
## Warning in stri_detect_regex(string, pattern, negate = negate, opts_regex =
## opts(pattern)): argument is not an atomic vector; coercing
##  Viticultural risk plot created
##  Viticultural regions list created
##  Risk map proportional areas table created
##  Range shift area table created
##  Viticultural risk table created
##  Report created
##  Report NOT saved to file
scari::create_risk_report(
  locality.iso = "usa",
  locality.name = "pennsylvania",
  locality.type = "state_province",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "United States"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)
##  proceeding without creating report output subdirectory folder
## Reading layer `ne_10m_admin_0_countries' from data source 
##   `C:\Users\tun83449\OneDrive - Temple University\Shared drives\slfClimate\projects\scari\scari\data-raw\ne_countries\ne_10m_admin_0_countries.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 258 features and 168 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -180 ymin: -90 xmax: 180 ymax: 83.6341
## Geodetic CRS:  WGS 84
##  Importing shapefiles from: C:/Users/tun83449/OneDrive - Temple University/Shared drives/slfClimate/projects/scari/scari/data-raw
## Reading layer `ne_10m_admin_1_states_provinces' from data source 
##   `C:\Users\tun83449\OneDrive - Temple University\Shared drives\slfClimate\projects\scari\scari\data-raw\ne_states_provinces\ne_10m_admin_1_states_provinces.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 4596 features and 121 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -180 ymin: -90 xmax: 180 ymax: 83.6341
## Geodetic CRS:  WGS 84
##  Data exist for locality
##  Suitability prediction type for IVR regions: buffer of 20000m around points
##  Risk maps plotted
##  Range shift map plotted
## Warning in stri_detect_regex(string, pattern, negate = negate, opts_regex =
## opts(pattern)): argument is not an atomic vector; coercing
##  Viticultural risk plot created
##  Viticultural regions list created
##  Risk map proportional areas table created
##  Range shift area table created
##  Viticultural risk table created
##  Report created
##  Report NOT saved to file
### USA
# the USA map usually comes including Alaska and hawaii, which we do not want

USA_current <- united_states_slf_risk_report[["risk_maps"]][["present_risk_map"]] +
  xlim(-125, -65) +
  ylim(25, 50)

USA_future <- united_states_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  xlim(-125, -65) +
  ylim(25, 50)

USA_shift <- united_states_slf_risk_report[["range_shift_map"]] +
  xlim(-125, -65) +
  ylim(25, 50)


#save
ggsave(
  USA_current,
  filename = file.path(here::here(), "vignette-outputs", "reports", "United States", "united_states_risk_map_present_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)

ggsave(
  USA_future,
  filename = file.path(here::here(), "vignette-outputs", "reports", "United States", "united_states_risk_map_2055_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)

ggsave(
  USA_shift,
  filename = file.path(here::here(), "vignette-outputs", "reports", "United States", "united_states_shift_map_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)

# save USA report for other uses
readr::write_rds(united_states_slf_risk_report, file = file.path(here::here(), "vignette-outputs", "reports", "United States", "united_states_slf_risk_report.rds"))

China

scari::create_risk_report(
  locality.iso = "chn", 
  locality.name = "china",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "China"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)
##  proceeding without creating report output subdirectory folder
## Reading layer `ne_10m_admin_0_countries' from data source 
##   `C:\Users\tun83449\OneDrive - Temple University\Shared drives\slfClimate\projects\scari\scari\data-raw\ne_countries\ne_10m_admin_0_countries.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 258 features and 168 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -180 ymin: -90 xmax: 180 ymax: 83.6341
## Geodetic CRS:  WGS 84
##  Importing shapefiles from: C:/Users/tun83449/OneDrive - Temple University/Shared drives/slfClimate/projects/scari/scari/data-raw
## Reading layer `ne_10m_admin_1_states_provinces' from data source 
##   `C:\Users\tun83449\OneDrive - Temple University\Shared drives\slfClimate\projects\scari\scari\data-raw\ne_states_provinces\ne_10m_admin_1_states_provinces.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 4596 features and 121 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -180 ymin: -90 xmax: 180 ymax: 83.6341
## Geodetic CRS:  WGS 84
##  Data exist for locality
##  Suitability prediction type for IVR regions: buffer of 20000m around points
##  Risk maps plotted
##  Range shift map plotted
## Warning in stri_detect_regex(string, pattern, negate = negate, opts_regex =
## opts(pattern)): argument is not an atomic vector; coercing
##  Viticultural risk plot created
##  Viticultural regions list created
##  Risk map proportional areas table created
##  Range shift area table created
##  Viticultural risk table created
##  Report created
##  Report NOT saved to file
# this report should have 2 IVR points
scari::create_risk_report(
  locality.iso = "chn",
  locality.name = "shandong",
  locality.type = "state_province",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "China"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)
##  proceeding without creating report output subdirectory folder
## Reading layer `ne_10m_admin_0_countries' from data source 
##   `C:\Users\tun83449\OneDrive - Temple University\Shared drives\slfClimate\projects\scari\scari\data-raw\ne_countries\ne_10m_admin_0_countries.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 258 features and 168 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -180 ymin: -90 xmax: 180 ymax: 83.6341
## Geodetic CRS:  WGS 84
##  Importing shapefiles from: C:/Users/tun83449/OneDrive - Temple University/Shared drives/slfClimate/projects/scari/scari/data-raw
## Reading layer `ne_10m_admin_1_states_provinces' from data source 
##   `C:\Users\tun83449\OneDrive - Temple University\Shared drives\slfClimate\projects\scari\scari\data-raw\ne_states_provinces\ne_10m_admin_1_states_provinces.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 4596 features and 121 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -180 ymin: -90 xmax: 180 ymax: 83.6341
## Geodetic CRS:  WGS 84
##  Data exist for locality
##  Suitability prediction type for IVR regions: buffer of 20000m around points
##  Risk maps plotted
##  Range shift map plotted
## Warning in stri_detect_regex(string, pattern, negate = negate, opts_regex =
## opts(pattern)): argument is not an atomic vector; coercing
##  Viticultural risk plot created
##  Viticultural regions list created
##  Risk map proportional areas table created
##  Range shift area table created
##  Viticultural risk table created
##  Report created
##  Report NOT saved to file
# this report should have no IVR records
scari::create_risk_report(
  locality.iso = "chn",
  locality.name = "yunnan",
  locality.type = "state_province",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "China"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)
##  proceeding without creating report output subdirectory folder
## Reading layer `ne_10m_admin_0_countries' from data source 
##   `C:\Users\tun83449\OneDrive - Temple University\Shared drives\slfClimate\projects\scari\scari\data-raw\ne_countries\ne_10m_admin_0_countries.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 258 features and 168 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -180 ymin: -90 xmax: 180 ymax: 83.6341
## Geodetic CRS:  WGS 84
##  Importing shapefiles from: C:/Users/tun83449/OneDrive - Temple University/Shared drives/slfClimate/projects/scari/scari/data-raw
## Reading layer `ne_10m_admin_1_states_provinces' from data source 
##   `C:\Users\tun83449\OneDrive - Temple University\Shared drives\slfClimate\projects\scari\scari\data-raw\ne_states_provinces\ne_10m_admin_1_states_provinces.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 4596 features and 121 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -180 ymin: -90 xmax: 180 ymax: 83.6341
## Geodetic CRS:  WGS 84
##  Data exist for locality
##  Suitability prediction type for IVR regions: buffer of 20000m around points
## Warning: [buffer] empty SpatVector
##  Risk maps plotted
##  Range shift map plotted
## Warning in stri_detect_regex(string, pattern, negate = negate, opts_regex =
## opts(pattern)): argument is not an atomic vector; coercing
##  Viticultural risk plot created
##  Viticultural regions list created
##  Risk map proportional areas table created
##  Range shift area table created
##  Viticultural risk table created
##  Report created
##  Report NOT saved to file
# it worked still so thats good

# save report for other uses
# readr::write_rds(china_slf_risk_report, file = file.path(here::here(), "vignette-outputs", "reports", "China", "china_slf_risk_report.rds"))

Viticultural shifts due to climate change

Now, I will apply this function for specific countries of future viticultural interest.

Morales-Castilla et al 2020 predicted that the following countries would experience a loss in suitability for viticulture under a 4C warming scenario of climate change:

highest losses: * Italy * Spain

others: * Turkey * South Africa * Portugal * mexico

Concurrently, they predicted that the following areas would experience a gain in suitability under the same scenario:

  • Pacific Northwestern States (USA)
  • New Zealand
  • Great Britain
  • Ireland
  • Sweden

Finally, some countries are expected to experience a more balanced ratio of losses and gains in suitability:

  • France

Another paper, Webb et al 2013 predicted analogous climates for specific Vitis cultivars under climate change. This paper focused more on predicting where specific cultivars might move as growers keep pace with climate change. Based on predicted climate shifts in temperature and precipitation, this study predicts that the following areas will be generally less suitable for Vitis cultivars in the future:

  • Central valley, California, USA
  • Hotter parts of Australia

Meanwhile, the following areas may increase in suitabiliy due to warming winter temperature minimums:

  • Michigan, USA
  • New Zealand

Countries experiencing a loss in viticultural suitability

# spain
scari::create_risk_report(
  locality.iso = "esp",
  locality.name = "spain",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "spain"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)

# italy
scari::create_risk_report(
  locality.iso = "ita",
  locality.name = "italy",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "Italy"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)

# portugal
scari::create_risk_report(
  locality.iso = "prt",
  locality.name = "portugal",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "Portugal"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)

# türkiye
scari::create_risk_report(
  locality.iso = "tur",
  locality.name = "türkiye",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "Turkey"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)


# south africa
scari::create_risk_report(
  locality.iso = "zaf",
  locality.name =  "south africa",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "South Africa"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)

# mexico
scari::create_risk_report(
  locality.iso = "mex",
  locality.name = "mexico",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "Mexico"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)
# the spain report came out with the the maps needing some work.
# The map is zoomed very far out because of some territories belonging to spain.
# I will try to limiting the x and y coordinates of the plot to zoom in.

spain_current <- spain_slf_risk_report[["risk_maps"]][["present_risk_map"]] +
  xlim(-10, 5) +
  ylim(35, 44)

spain_future <- spain_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  xlim(-10, 5) +
  ylim(35, 44)

spain_shift <- spain_slf_risk_report[["range_shift_map"]] +
  xlim(-10, 5) +
  ylim(35, 44)


#save
ggsave(
  spain_current,
  filename = file.path(here::here(), "vignette-outputs", "reports", "Spain", "Spain_risk_map_present_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)

ggsave(
  spain_future,
  filename = file.path(here::here(), "vignette-outputs", "reports", "Spain", "Spain_risk_map_2055_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)

ggsave(
  spain_shift,
  filename = file.path(here::here(), "vignette-outputs", "reports", "Spain", "Spain_range_shift_map_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)

# the canary islands also have a number of vineyards so I will create maps of just those
canary_current <- spain_slf_risk_report[["risk_maps"]][["present_risk_map"]] +
  xlim(-19, -13) +
  ylim(27, 30) +
  labs(subtitle = "Spain: canary islands")

canary_future <- spain_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  xlim(-19, -13) +
  ylim(27, 30) +
  labs(subtitle = "Spain: canary islands")

canary_shift <- spain_slf_risk_report[["range_shift_map"]] +
  xlim(-19, -13) +
  ylim(27, 30) +
  labs(subtitle = "Spain: canary islands")


#save
ggsave(
  canary_current,
  filename = file.path(here::here(), "vignette-outputs", "reports", "Spain", "canary_islands_risk_map_present_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)

ggsave(
  canary_future,
  filename = file.path(here::here(), "vignette-outputs", "reports", "Spain", "canary_islands_risk_map_2055_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)

ggsave(
  canary_shift,
  filename = file.path(here::here(), "vignette-outputs", "reports", "Spain", "canary_islands_range_shift_map_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)
# the spain report came out with the the maps needing some work.
# The map is zoomed very far out because of some territories belonging to spain.
# I will try to limiting the x and y coordinates of the plot to zoom in.

portugal_current <- portugal_slf_risk_report[["risk_maps"]][["present_risk_map"]] +
  xlim(-18, -6) +
  ylim(32, 42)

portugal_future <- portugal_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  xlim(-18, -6) +
  ylim(32, 42)

portugal_shift <- portugal_slf_risk_report[["range_shift_map"]] +
  xlim(-18, -6) +
  ylim(32, 42)


#save
ggsave(
  portugal_current,
  filename = file.path(here::here(), "vignette-outputs", "reports", "Portugal", "portugal_risk_map_present_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)

ggsave(
  portugal_future,
  filename = file.path(here::here(), "vignette-outputs", "reports", "Portugal", "portugal_risk_map_2055_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)

ggsave(
  portugal_shift,
  filename = file.path(here::here(), "vignette-outputs", "reports", "Portugal", "portugal_range_shift_map_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)
south_africa_current <- south_africa_slf_risk_report[["risk_maps"]][["present_risk_map"]] +
  xlim(15, 35) +
  ylim(-35, -22)

south_africa_future <- south_africa_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  xlim(15, 35) +
  ylim(-35, -22)

south_africa_shift <- south_africa_slf_risk_report[["range_shift_map"]] +
  xlim(15, 35) +
  ylim(-35, -22)


#save
ggsave(
  south_africa_current,
  filename = file.path(here::here(), "vignette-outputs", "reports", "South Africa", "south_africa_risk_map_present_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)

ggsave(
  south_africa_future,
  filename = file.path(here::here(), "vignette-outputs", "reports", "South Africa", "south_africa_risk_map_2055_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)

ggsave(
  south_africa_shift,
  filename = file.path(here::here(), "vignette-outputs", "reports", "South Africa", "south_africa_range_shift_map_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)

Countries experiencing a gain in viticultural suitability

# united kingdom
scari::create_risk_report(
  locality.iso = "gbr",
  locality.name = "united kingdom",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "United Kingdom"),
  create.dir = TRUE,
  save.report = FALSE,
  buffer.dist = 20000
)

# Ireland
scari::create_risk_report(
  locality.iso = "irl",
  locality.name = "Ireland",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "Ireland"),
  create.dir = TRUE,
  save.report = FALSE,
  buffer.dist = 20000
)

# New zealand
scari::create_risk_report(
  locality.iso = "nzl",
  locality.name = "new zealand",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "New Zealand"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)

# sweden
scari::create_risk_report(
  locality.iso = "swe",
  locality.name = "sweden",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "sweden"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)
# michigan
scari::create_risk_report(
  locality.iso = "usa",
  locality.name = "michigan",
  locality.type = "state_province",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "United States"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)

# oregon
scari::create_risk_report(
  locality.iso = "usa",
  locality.name = "oregon",
  locality.type = "state_province",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "United States"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)

# washington
scari::create_risk_report(
  locality.iso = "usa",
  locality.name = "washington",
  locality.type = "state_province",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "United States"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)

# tasmania
scari::create_risk_report(
  locality.iso = "aus",
  locality.name = "tasmania",
  locality.type = "state_province",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "Australia"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)
# the spain report came out with the the maps needing some work.
# The map is zoomed very far out because of some territories belonging to spain.
# I will try to limiting the x and y coordinates of the plot to zoom in.

new_zealand_current <- new_zealand_slf_risk_report[["risk_maps"]][["present_risk_map"]] +
  xlim(165, 180) +
  ylim(-48, -34)

new_zealand_future <- new_zealand_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  xlim(165, 180) +
  ylim(-48, -34)

new_zealand_shift <- new_zealand_slf_risk_report[["range_shift_map"]] +
  xlim(165, 180) +
  ylim(-48, -34)


#save
ggsave(
  new_zealand_current,
  filename = file.path(here::here(), "vignette-outputs", "reports", "New Zealand", "new_zealand_risk_map_present_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)

ggsave(
  new_zealand_future,
  filename = file.path(here::here(), "vignette-outputs", "reports", "New Zealand", "new_zealand_risk_map_2055_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)

ggsave(
  new_zealand_shift,
  filename = file.path(here::here(), "vignette-outputs", "reports", "New Zealand", "new_zealand_range_shift_map_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)

other countries of interest

# countries of interest
# chile
scari::create_risk_report(
  locality.iso = "chl",
  locality.name = "chile",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "Chile"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)

# australia
scari::create_risk_report(
  locality.iso = "aus",
  locality.name = "australia",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "Australia"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)

# romania
scari::create_risk_report(
  locality.iso = "rou",
  locality.name = "romania",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "Romania"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)

# argentina
scari::create_risk_report(
  locality.iso = "arg",
  locality.name = "argentina",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "Argentina"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)

# georgia
scari::create_risk_report(
  locality.iso = "geo",
  locality.name = "georgia",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "Georgia"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)

# russia
scari::create_risk_report(
  locality.iso = "rus",
  locality.name = "russia",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "Russia"),
  create.dir = TRUE,
  save.report = FALSE,
  buffer.dist = 20000
)
# no shapefile data exist
australia_current <- australia_slf_risk_report[["risk_maps"]][["present_risk_map"]] +
  xlim(110, 155) +
  ylim(-44, -10)

australia_future <- australia_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  xlim(110, 155) +
  ylim(-44, -10)

australia_shift <- australia_slf_risk_report[["range_shift_map"]] +
  xlim(110, 155) +
  ylim(-44, -10)


#save
ggsave(
  australia_current,
  filename = file.path(here::here(), "vignette-outputs", "reports", "Australia", "australia_risk_map_present_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)

ggsave(
  australia_future,
  filename = file.path(here::here(), "vignette-outputs", "reports", "Australia", "australia_risk_map_2055_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)

ggsave(
  australia_shift,
  filename = file.path(here::here(), "vignette-outputs", "reports", "Australia", "australia_range_shift_map_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)
russia_current <- russia_slf_risk_report[["risk_maps"]][["present_risk_map"]] +
  xlim(20, 180) 

russia_future <- russia_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  xlim(20, 180) 

russia_shift <- russia_slf_risk_report[["range_shift_map"]] +
  xlim(20, 180) 


#save
ggsave(
  russia_current,
  filename = file.path(here::here(), "vignette-outputs", "reports", "Russia", "russia_risk_map_present_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)

ggsave(
  russia_future,
  filename = file.path(here::here(), "vignette-outputs", "reports", "Russia", "russia_risk_map_2055_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)

ggsave(
  russia_shift,
  filename = file.path(here::here(), "vignette-outputs", "reports", "Russia", "russia_range_shift_map_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)
chile_current <- chile_slf_risk_report[["risk_maps"]][["present_risk_map"]] +
  xlim(-78, -65) 

chile_future <- chile_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  xlim(-78, -65) 

chile_shift <- chile_slf_risk_report[["range_shift_map"]] +
  xlim(-78, -65) 


#save
ggsave(
  chile_current,
  filename = file.path(here::here(), "vignette-outputs", "reports", "Chile", "chile_risk_map_present_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)

ggsave(
  chile_future,
  filename = file.path(here::here(), "vignette-outputs", "reports", "Chile", "chile_risk_map_2055_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)

ggsave(
  chile_shift,
  filename = file.path(here::here(), "vignette-outputs", "reports", "Chile", "chile_range_shift_map_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)

other areas of CC interest

These areas experienced a significant increase in SLF risk on the main global maps.

# finland
# projected gain of slf suitability here
scari::create_risk_report(
  locality.iso = "fin",
  locality.name = "finland",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "finland"),
  create.dir = TRUE,
  save.report = FALSE,
  buffer.dist = 20000
)

Western europe

# germany
scari::create_risk_report(
  locality.iso = "DEU",
  locality.name = "germany",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "Germany"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)


# france
scari::create_risk_report(
  locality.iso = "fra",
  locality.name = "france",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "France"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)


# portugual and italy done above
france_current <- france_slf_risk_report[["risk_maps"]][["present_risk_map"]] +
  xlim(-5, 10) +
  ylim(41, 51)

france_future <- france_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  xlim(-5, 10) +
  ylim(41, 51)

france_shift <- france_slf_risk_report[["range_shift_map"]] +
  xlim(-5, 10) +
  ylim(41, 51)


#save
ggsave(
  france_current,
  filename = file.path(here::here(), "vignette-outputs", "reports", "France", "france_risk_map_present_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)

ggsave(
  france_future,
  filename = file.path(here::here(), "vignette-outputs", "reports", "France", "france_risk_map_2055_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)

ggsave(
  france_shift,
  filename = file.path(here::here(), "vignette-outputs", "reports", "France", "france_range_shift_map_edited.jpg"),
  height = 8,
  width = 10,
  device = jpeg,
  dpi = "retina"
)

Eastern Europe

# greece
scari::create_risk_report(
  locality.iso = "GRC",
  locality.name = "greece",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "greece"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)


# austria
scari::create_risk_report(
  locality.iso = "AUT",
  locality.name = "austria",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "Austria"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)

# hungary
scari::create_risk_report(
  locality.iso = "HUN",
  locality.name = "hungary",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "Hungary"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)

# czech republic (Czechia)
scari::create_risk_report(
  locality.iso = "CZE",
  locality.name = "Czechia",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "Czechia"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)

# other
# estonia
scari::create_risk_report(
  locality.iso = "est",
  locality.name = "estonia",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "Estonia"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)

# latvia
scari::create_risk_report(
  locality.iso = "lva",
  locality.name = "lativa",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "Lativa"),
  create.dir = TRUE,
  save.report = FALSE,
  buffer.dist = 20000
)

# lithuania
scari::create_risk_report(
  locality.iso = "ltu",
  locality.name = "lithuania",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "Lithuania"),
  create.dir = TRUE,
  save.report = FALSE,
  buffer.dist = 20000
)

# denmark
scari::create_risk_report(
  locality.iso = "dnk",
  locality.name = "denmark",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "Denmark"),
  create.dir = TRUE,
  save.report = FALSE,
  buffer.dist = 20000
)

# poland
scari::create_risk_report(
  locality.iso = "pol",
  locality.name = "poland",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "Poland"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)

Africa

# algeria
scari::create_risk_report(
  locality.iso = "DZA",
  locality.name = "algeria",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "Algeria"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)

## south africa above

N America

# canada
scari::create_risk_report(
  locality.iso = "CAN",
  locality.name = "canada",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "Canada"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)

# mexico above

West Asia

# turkey
scari::create_risk_report(
  locality.iso = "TUR",
  locality.name = "turkey",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "Turkey"),
  create.dir = TRUE,
  save.report = FALSE,
  buffer.dist = 20000
)


# georgia above

East Asia

## china above

# south korea
scari::create_risk_report(
  locality.iso = "KOR",
  locality.name = "south korea",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "South Korea"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)

# japan
scari::create_risk_report(
  locality.iso = "JPN",
  locality.name = "japan",
  locality.type = "country",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "Japan"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)


# save reports for other uses
readr::write_rds(japan_slf_risk_report, file = file.path(here::here(), "vignette-outputs", "reports", "Japan", "japan_slf_risk_report.rds"))

readr::write_rds(south_korea_slf_risk_report, file = file.path(here::here(), "vignette-outputs", "reports", "Republic of Korea", "south_korea_slf_risk_report.rds"))

Other

## doesnt work for some reason

# New zealand
scari::create_risk_report(
  locality.iso = "nzl",
  locality.name = "marlborough",
  locality.type = "state_province",
  mypath = file.path(here::here(), "vignette-outputs", "reports", "New Zealand"),
  create.dir = FALSE,
  save.report = FALSE,
  buffer.dist = 20000
)

This brings us to the end of my analysis on the risk of SLF under climate change and for specific regions!

References

  1. Webb, L. B., Watterson, I., Bhend, J., Whetton, P. H., & Barlow, E. W. R. (2013). Global climate analogues for winegrowing regions in future periods: Projections of temperature and precipitation. Australian Journal of Grape and Wine Research, 19(3), 331–341. https://doi.org/10.1111/ajgw.12045

  2. Morales-Castilla, I., García de Cortázar-Atauri, I., Cook, B. I., Lacombe, T., Parker, A., van Leeuwen, C., Nicholas, K. A., & Wolkovich, E. M. (2020). Diversity buffers winegrowing regions from climate change losses. Proceedings of the National Academy of Sciences, 117(6), 2864–2869. https://doi.org/10.1073/pnas.1906731117

Create faceted maps

First I will facet some examples of different risk scenarios for SLF with their respective risk maps. I will use Romania, the USA and Spain. Romania is an example of a country with a high shift toward the regional model predictions because almost all viticultural regions shift from extreme to high suitability, highlighting the importance of the regional model. The USA exhibits this same trend, but not with the same strength that Romania does. Viticultural regions in spain exhibit a general shift to unsuitability in both models. The regional model seems to display risk under the current climate, but that risk disappears with climate change.

Before I perform this operation, I will save reports as a .Rdata file so that I can reuse them later as needed, without running the entire script again.

Example countries

romania_risk_plot <- romania_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "A") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )

# edits
# remove geom_text
romania_risk_plot <- romania_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
romania_risk_plot$data[[4]]$size <- 1.5
romania_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#romania_risk_plot$data[[3]]$linewidth <- 0.1

romania_risk_plot <- ggplot_gtable(romania_risk_plot) %>%
  wrap_ggplot_grob()



united_states_risk_plot <- united_states_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "C") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )

united_states_risk_plot <- united_states_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
united_states_risk_plot$data[[4]]$size <- 1.5
united_states_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#united_states_risk_plot$data[[3]]$linewidth <- 0.1

united_states_risk_plot <- ggplot_gtable(united_states_risk_plot) %>%
  wrap_ggplot_grob()

  

australia_risk_plot <- australia_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "E") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )

australia_risk_plot <- australia_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
australia_risk_plot$data[[4]]$size <- 1.5
australia_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#australia_risk_plot$data[[3]]$linewidth <- 0.1

australia_risk_plot <- ggplot_gtable(australia_risk_plot) %>%
  wrap_ggplot_grob()


  # edit maps

romania_risk_map <- romania_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "B") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(0.1, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )


romania_risk_map <- ggplot_build(romania_risk_map)
# edit point size
romania_risk_map$data[[3]]$size <- 1.5

romania_risk_map <- ggplot_gtable(romania_risk_map) %>%
  wrap_ggplot_grob()



USA_risk_map <-  united_states_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "D") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(0.1, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    ) +
  xlim(-125, -65) +
  ylim(25, 50)

USA_risk_map <- ggplot_build(USA_risk_map)
# edit point size
USA_risk_map$data[[3]]$size <- 1.5

USA_risk_map <- ggplot_gtable(USA_risk_map) %>%
  wrap_ggplot_grob()
 


australia_risk_map <- australia_future +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "F") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(0.15, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )
  
australia_risk_map <- ggplot_build(australia_risk_map)
# edit point size
australia_risk_map$data[[3]]$size <- 1.5
# rebuild plot
australia_risk_map <- ggplot_gtable(australia_risk_map) %>%
  wrap_ggplot_grob()
#layout <- c(
#  area(t = 1, b = 1, l = 1, r = 1),
#  area(t = 1, b = 1, l = 2, r = 2),
##  area(t = 2, b = 2, l = 1, r = 1),
#  area(t = 2, b = 2, l = 2, r = 3),
#  area(t = 3, b = 3, l = 1, r = 1),
#  area(t = 3, b = 3, l = 2, r = 2)
#)

example_countries_patchwork <- (
  # romania top row
  romania_risk_plot + plot_spacer() + romania_risk_map + 
  # USA 2nd row
  united_states_risk_plot + plot_spacer() + USA_risk_map + 
  # australia 3rd row
  australia_risk_plot + plot_spacer() + australia_risk_map
  ) +
  # annotation
  plot_annotation(title = "Differential risk shift due to climate change among countries") +
  plot_layout(ncol = 3, widths = c(1, 0, -1)) 
ggsave(
  example_countries_patchwork, 
  filename = file.path(here::here(), "vignette-outputs", "figures", "differential_risk_shift_countries.jpg"),
  height = 10, 
  width = 8,
  device = jpeg,
  dpi = 500
  )

US States

washington_risk_plot <- washington_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "A") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold")
    )

# edits
# remove geom_text
washington_risk_plot <- washington_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
washington_risk_plot$data[[4]]$size <- 1.5
washington_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#washington_risk_plot$data[[3]]$linewidth <- 0.1

washington_risk_plot <- ggplot_gtable(washington_risk_plot) %>%
  wrap_ggplot_grob()



oregon_risk_plot <- oregon_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "C") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold")
    )

oregon_risk_plot <- oregon_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
oregon_risk_plot$data[[4]]$size <- 1.5
oregon_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#oregon_risk_plot$data[[3]]$linewidth <- 0.1

oregon_risk_plot <- ggplot_gtable(oregon_risk_plot) %>%
  wrap_ggplot_grob()

  

michigan_risk_plot <- michigan_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "E") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold")
    )

michigan_risk_plot <- michigan_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
michigan_risk_plot$data[[4]]$size <- 1.5
michigan_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#michigan_risk_plot$data[[3]]$linewidth <- 0.1

michigan_risk_plot <- ggplot_gtable(michigan_risk_plot) %>%
  wrap_ggplot_grob()


  # edit maps

washington_risk_map <- washington_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "B") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(-0.1, 0.9),
    plot.tag = element_text(face = "bold")
    )


washington_risk_map <- ggplot_build(washington_risk_map)
# edit point size
washington_risk_map$data[[3]]$size <- 1.5

washington_risk_map <- ggplot_gtable(washington_risk_map) %>%
  wrap_ggplot_grob()



oregon_risk_map <-  oregon_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "D") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(-0.1, 0.9),
    plot.tag = element_text(face = "bold")
    ) 

oregon_risk_map <- ggplot_build(oregon_risk_map)
# edit point size
oregon_risk_map$data[[3]]$size <- 1.5

oregon_risk_map <- ggplot_gtable(oregon_risk_map) %>%
  wrap_ggplot_grob()
 


michigan_risk_map <- michigan_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "F") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(-0.1, 0.9),
    plot.tag = element_text(face = "bold")
    )
  
michigan_risk_map <- ggplot_build(michigan_risk_map)
# edit point size
michigan_risk_map$data[[3]]$size <- 1.5
# rebuild plot
michigan_risk_map <- ggplot_gtable(michigan_risk_map) %>%
  wrap_ggplot_grob()
example_states_patchwork <- (
  # washington top row
  washington_risk_plot + plot_spacer() + washington_risk_map + 
  # USA 2nd row
  oregon_risk_plot + plot_spacer() + oregon_risk_map + 
  # michigan 3rd row
  michigan_risk_plot + plot_spacer() + michigan_risk_map
  ) +
  # annotation
  plot_annotation(title = "Risk shift in US states of future interest for viticulture") +
  plot_layout(ncol = 3, nrow = 3, widths = unit(c(5.5, 1, 5.5), "cm"), heights = unit(5.5, "cm"))
ggsave(
  example_states_patchwork, 
  filename = file.path(here::here(), "vignette-outputs", "figures", "risk_shift_viticultural_states.jpg"),
  height = 8, 
  width = 10,
  device = jpeg,
  dpi = 500
  )

Viticultural regions of interest- Oceania

new_zealand_risk_plot <- new_zealand_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "A") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )

# edits
# remove geom_text
new_zealand_risk_plot <- new_zealand_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
new_zealand_risk_plot$data[[4]]$size <- 1.5
new_zealand_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#new_zealand_risk_plot$data[[3]]$linewidth <- 0.1

new_zealand_risk_plot <- ggplot_gtable(new_zealand_risk_plot) %>%
  wrap_ggplot_grob()


# australia
australia_risk_plot <- australia_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "C") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )

# edits
# remove geom_text
australia_risk_plot <- australia_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
australia_risk_plot$data[[4]]$size <- 1.5
australia_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#australia_risk_plot$data[[3]]$linewidth <- 0.1

australia_risk_plot <- ggplot_gtable(australia_risk_plot) %>%
  wrap_ggplot_grob()



# tasmania
tasmania_risk_plot <- tasmania_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "E") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )

tasmania_risk_plot <- tasmania_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
tasmania_risk_plot$data[[4]]$size <- 1.5
tasmania_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#tasmania_risk_plot$data[[3]]$linewidth <- 0.1

tasmania_risk_plot <- ggplot_gtable(tasmania_risk_plot) %>%
  wrap_ggplot_grob()


  # edit maps
# new zealand
new_zealand_risk_map <- new_zealand_future +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "B") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(0, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )


new_zealand_risk_map <- ggplot_build(new_zealand_risk_map)
# edit point size
new_zealand_risk_map$data[[3]]$size <- 1.5

new_zealand_risk_map <- ggplot_gtable(new_zealand_risk_map) %>%
  wrap_ggplot_grob()



# australia
australia_risk_map <- australia_future +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "D") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(-0.05, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )


australia_risk_map <- ggplot_build(australia_risk_map)
# edit point size
australia_risk_map$data[[3]]$size <- 1.5

australia_risk_map <- ggplot_gtable(australia_risk_map) %>%
  wrap_ggplot_grob()


# tasmania
tasmania_risk_map <- tasmania_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "F") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(0, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )
  
tasmania_risk_map <- ggplot_build(tasmania_risk_map)
# edit point size
tasmania_risk_map$data[[3]]$size <- 1.5
# rebuild plot
tasmania_risk_map <- ggplot_gtable(tasmania_risk_map) %>%
  wrap_ggplot_grob()
oceania_patchwork <- (
  # new_zealand top row
  new_zealand_risk_plot + plot_spacer() + new_zealand_risk_map + 
  # australia
  australia_risk_plot + plot_spacer() + australia_risk_map +
  # tasmania bottom row
  tasmania_risk_plot + plot_spacer() + tasmania_risk_map
  ) +
  # annotation
  plot_annotation(
    title = "Risk shift in regions of future interest for viticulture",
    subtitle = "Oceania"
    ) +
  plot_layout(ncol = 3, nrow = 3, widths = unit(c(5.5, 1, 5.5), "cm"), heights = unit(5.5, "cm"))
ggsave(
  oceania_patchwork, 
  filename = file.path(here::here(), "vignette-outputs", "figures", "future_viticultural_regions_oceania.jpg"),
  height = 10, 
  width = 8,
  device = jpeg,
  dpi = "retina"
  )

Viticultural regions of interest- South America

chile_risk_plot <- chile_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "A") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold")
    )

# edits
# remove geom_text
chile_risk_plot <- chile_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
chile_risk_plot$data[[4]]$size <- 1.5
chile_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#chile_risk_plot$data[[3]]$linewidth <- 0.1

chile_risk_plot <- ggplot_gtable(chile_risk_plot) %>%
  wrap_ggplot_grob()


argentina_risk_plot <- argentina_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "C") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold")
    )

argentina_risk_plot <- argentina_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
argentina_risk_plot$data[[4]]$size <- 1.5
argentina_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#argentina_risk_plot$data[[3]]$linewidth <- 0.1

argentina_risk_plot <- ggplot_gtable(argentina_risk_plot) %>%
  wrap_ggplot_grob()


  # edit maps

chile_risk_map <- chile_future +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "B") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold")
    )


chile_risk_map <- ggplot_build(chile_risk_map)
# edit point size
chile_risk_map$data[[3]]$size <- 1.5

chile_risk_map <- ggplot_gtable(chile_risk_map) %>%
  wrap_ggplot_grob()


argentina_risk_map <- argentina_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "D") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(0.15, 0.9),
    plot.tag = element_text(face = "bold")
    )
  
argentina_risk_map <- ggplot_build(argentina_risk_map)
# edit point size
argentina_risk_map$data[[3]]$size <- 1.5
# rebuild plot
argentina_risk_map <- ggplot_gtable(argentina_risk_map) %>%
  wrap_ggplot_grob()
SAmerica_patchwork <- (
  chile_risk_plot + argentina_risk_plot +
  plot_spacer() + plot_spacer() +
  chile_risk_map + argentina_risk_map 
  ) +
  # annotation
  plot_annotation(
    title = "Risk shift in regions of future interest for viticulture",
    subtitle = "South America"
    ) +
  plot_layout(ncol = 2, nrow = 3, widths = unit(5, "cm"), heights = unit(c(5, 0, 7.5), "cm"))
ggsave(
  SAmerica_patchwork, 
  filename = file.path(here::here(), "vignette-outputs", "figures", "future_viticultural_regions_SAmerica.jpg"),
  height = 8, 
  width = 8,
  device = jpeg,
  dpi = "retina"
  )

Viticultural regions of interest- Western Europe

# portugal
portugal_risk_plot <- portugal_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "A") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )

# edits
# remove geom_text
portugal_risk_plot <- portugal_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
portugal_risk_plot$data[[4]]$size <- 1.5
portugal_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#portugal_risk_plot$data[[3]]$linewidth <- 0.1

portugal_risk_plot <- ggplot_gtable(portugal_risk_plot) %>%
  wrap_ggplot_grob()


# france
france_risk_plot <- france_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "C") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )

# edits
# remove geom_text
france_risk_plot <- france_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
france_risk_plot$data[[4]]$size <- 1.5
france_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#france_risk_plot$data[[3]]$linewidth <- 0.1

france_risk_plot <- ggplot_gtable(france_risk_plot) %>%
  wrap_ggplot_grob()

# germany
germany_risk_plot <- germany_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "E") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )

germany_risk_plot <- germany_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
germany_risk_plot$data[[4]]$size <- 1.5
germany_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#germany_risk_plot$data[[3]]$linewidth <- 0.1

germany_risk_plot <- ggplot_gtable(germany_risk_plot) %>%
  wrap_ggplot_grob()


# italy
italy_risk_plot <- italy_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "G") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )

italy_risk_plot <- italy_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
italy_risk_plot$data[[4]]$size <- 1.5
italy_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#italy_risk_plot$data[[3]]$linewidth <- 0.1

italy_risk_plot <- ggplot_gtable(italy_risk_plot) %>%
  wrap_ggplot_grob()


# edit maps
# portugal
portugal_risk_map <- portugal_future +
  xlim(-10, -6) +
  ylim(37, 42) +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "B") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(0.1, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )


portugal_risk_map <- ggplot_build(portugal_risk_map)
# edit point size
portugal_risk_map$data[[3]]$size <- 1.5

portugal_risk_map <- ggplot_gtable(portugal_risk_map) %>%
  wrap_ggplot_grob()



# france
france_risk_map <- france_future +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "D") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(0.1, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )


france_risk_map <- ggplot_build(france_risk_map)
# edit point size
france_risk_map$data[[3]]$size <- 1.5

france_risk_map <- ggplot_gtable(france_risk_map) %>%
  wrap_ggplot_grob()

# germany map
germany_risk_map <- germany_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "F") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(0.05, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )
  
germany_risk_map <- ggplot_build(germany_risk_map)
# edit point size
germany_risk_map$data[[3]]$size <- 1.5
# rebuild plot
germany_risk_map <- ggplot_gtable(germany_risk_map) %>%
  wrap_ggplot_grob()
  
# italy map
italy_risk_map <- italy_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "H") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(0.05, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )
  
italy_risk_map <- ggplot_build(italy_risk_map)
# edit point size
italy_risk_map$data[[3]]$size <- 1.5
# rebuild plot
italy_risk_map <- ggplot_gtable(italy_risk_map) %>%
  wrap_ggplot_grob()
west_europe_patchwork <- (
  portugal_risk_plot + plot_spacer() + portugal_risk_map +
  france_risk_plot + plot_spacer() + france_risk_map +
  germany_risk_plot + plot_spacer() + germany_risk_map +
  italy_risk_plot + plot_spacer() + italy_risk_map 
  ) +
  # annotation
  plot_annotation(
    title = "Risk shift in regions of future interest for viticulture",
    subtitle = "Western Europe"
    ) +
  plot_layout(ncol = 3, nrow = 4, widths = unit(c(5.5, 1, 5.5), "cm"), heights = unit(5.5, "cm"))
ggsave(
  west_europe_patchwork, 
  filename = file.path(here::here(), "vignette-outputs", "figures", "future_viticultural_regions_western_europe.jpg"),
  height = 12, 
  width = 8,
  device = jpeg,
  dpi = "retina"
  )

Viticultural regions of interest- Eastern Europe

# portugal
austria_risk_plot <- austria_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "A") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )

# edits
# remove geom_text
austria_risk_plot <- austria_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
austria_risk_plot$data[[4]]$size <- 1.5
austria_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#austria_risk_plot$data[[3]]$linewidth <- 0.1

austria_risk_plot <- ggplot_gtable(austria_risk_plot) %>%
  wrap_ggplot_grob()


# france
hungary_risk_plot <- hungary_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "C") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )

# edits
# remove geom_text
hungary_risk_plot <- hungary_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
hungary_risk_plot$data[[4]]$size <- 1.5
hungary_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#hungary_risk_plot$data[[3]]$linewidth <- 0.1

hungary_risk_plot <- ggplot_gtable(hungary_risk_plot) %>%
  wrap_ggplot_grob()

# czechia
czechia_risk_plot <- czechia_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "E") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )

czechia_risk_plot <- czechia_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
czechia_risk_plot$data[[4]]$size <- 1.5
czechia_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#czechia_risk_plot$data[[3]]$linewidth <- 0.1

czechia_risk_plot <- ggplot_gtable(czechia_risk_plot) %>%
  wrap_ggplot_grob()


# italy
greece_risk_plot <- greece_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "G") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )

greece_risk_plot <- greece_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
greece_risk_plot$data[[4]]$size <- 1.5
greece_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#greece_risk_plot$data[[3]]$linewidth <- 0.1

greece_risk_plot <- ggplot_gtable(greece_risk_plot) %>%
  wrap_ggplot_grob()


# edit maps
# hungary
austria_risk_map <- austria_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "B") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(0.1, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )


austria_risk_map <- ggplot_build(austria_risk_map)
# edit point size
austria_risk_map$data[[3]]$size <- 1.5

austria_risk_map <- ggplot_gtable(austria_risk_map) %>%
  wrap_ggplot_grob()



# hungary
hungary_risk_map <- hungary_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "D") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(0.1, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )


hungary_risk_map <- ggplot_build(hungary_risk_map)
# edit point size
hungary_risk_map$data[[3]]$size <- 1.5

hungary_risk_map <- ggplot_gtable(hungary_risk_map) %>%
  wrap_ggplot_grob()

# czechia map
czechia_risk_map <- czechia_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "F") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(0.1, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )
  
czechia_risk_map <- ggplot_build(czechia_risk_map)
# edit point size
czechia_risk_map$data[[3]]$size <- 1.5
# rebuild plot
czechia_risk_map <- ggplot_gtable(czechia_risk_map) %>%
  wrap_ggplot_grob()
  
# greece map
greece_risk_map <- greece_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "H") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(0.1, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )
  
greece_risk_map <- ggplot_build(greece_risk_map)
# edit point size
greece_risk_map$data[[3]]$size <- 1.5
# rebuild plot
greece_risk_map <- ggplot_gtable(greece_risk_map) %>%
  wrap_ggplot_grob()
east_europe_patchwork <- (
  austria_risk_plot + plot_spacer() + austria_risk_map +
  hungary_risk_plot + plot_spacer() + hungary_risk_map +
  czechia_risk_plot + plot_spacer() + czechia_risk_map +
  greece_risk_plot + plot_spacer() + greece_risk_map 
  ) +
  # annotation
  plot_annotation(
    title = "Risk shift in regions of future interest for viticulture",
    subtitle = "Eastern Europe"
    ) +
  plot_layout(ncol = 3, nrow = 4, widths = unit(c(5.5, 1, 5.5), "cm"), heights = unit(5.5, "cm"))
ggsave(
  east_europe_patchwork, 
  filename = file.path(here::here(), "vignette-outputs", "figures", "future_viticultural_regions_eastern_europe.jpg"),
  height = 12, 
  width = 8,
  device = jpeg,
  dpi = "retina"
  )

Viticultural regions of interest- Africa

# south_africa
south_africa_risk_plot <- south_africa_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "A") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )
# edits
# remove geom_text
south_africa_risk_plot <- south_africa_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
south_africa_risk_plot$data[[4]]$size <- 1.5
south_africa_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#algeria_risk_plot$data[[3]]$linewidth <- 0.1

south_africa_risk_plot <- ggplot_gtable(south_africa_risk_plot) %>%
  wrap_ggplot_grob()



# algeria
algeria_risk_plot <- algeria_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "C") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )

# edits
# remove geom_text
algeria_risk_plot <- algeria_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
algeria_risk_plot$data[[4]]$size <- 1.5
algeria_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#algeria_risk_plot$data[[3]]$linewidth <- 0.1

algeria_risk_plot <- ggplot_gtable(algeria_risk_plot) %>%
  wrap_ggplot_grob()


# edit maps
# south_africa
south_africa_risk_map <- south_africa_future +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "B") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(0.1, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )


south_africa_risk_map <- ggplot_build(south_africa_risk_map)
# edit point size
south_africa_risk_map$data[[3]]$size <- 1.5

south_africa_risk_map <- ggplot_gtable(south_africa_risk_map) %>%
  wrap_ggplot_grob()


# algeria
algeria_risk_map <- algeria_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "D") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(0.1, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )


algeria_risk_map <- ggplot_build(algeria_risk_map)
# edit point size
algeria_risk_map$data[[3]]$size <- 1.5

algeria_risk_map <- ggplot_gtable(algeria_risk_map) %>%
  wrap_ggplot_grob()
africa_patchwork <- (
  south_africa_risk_plot + plot_spacer() + south_africa_risk_map +
  algeria_risk_plot + plot_spacer() + algeria_risk_map
  ) +
  # annotation
  plot_annotation(
    title = "Risk shift in regions of future interest for viticulture",
    subtitle = "Africa"
    ) +
  plot_layout(ncol = 3, nrow = 2, widths = unit(c(5.5, 1, 5.5), "cm"), heights = unit(5.5, "cm"))
ggsave(
  africa_patchwork, 
  filename = file.path(here::here(), "vignette-outputs", "figures", "future_viticultural_regions_africa.jpg"),
  height = 8, 
  width = 8,
  device = jpeg,
  dpi = "retina"
  )

Viticultural regions of interest- North America

# canada
canada_risk_plot <- canada_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "A") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )

# edits
# remove geom_text
canada_risk_plot <- canada_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
canada_risk_plot$data[[4]]$size <- 1.5
canada_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#canada_risk_plot$data[[3]]$linewidth <- 0.1

canada_risk_plot <- ggplot_gtable(canada_risk_plot) %>%
  wrap_ggplot_grob()



# mexico
mexico_risk_plot <- mexico_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "C") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )

# edits
# remove geom_text
mexico_risk_plot <- mexico_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
mexico_risk_plot$data[[4]]$size <- 1.5
mexico_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#mexico_risk_plot$data[[3]]$linewidth <- 0.1

mexico_risk_plot <- ggplot_gtable(mexico_risk_plot) %>%
  wrap_ggplot_grob()


# edit maps
# canada
canada_risk_map <- canada_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "B") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(0.1, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )


canada_risk_map <- ggplot_build(canada_risk_map)
# edit point size
canada_risk_map$data[[3]]$size <- 1.5

canada_risk_map <- ggplot_gtable(canada_risk_map) %>%
  wrap_ggplot_grob()


# mexico
mexico_risk_map <- mexico_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "D") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(0.1, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )


mexico_risk_map <- ggplot_build(mexico_risk_map)
# edit point size
mexico_risk_map$data[[3]]$size <- 1.5

mexico_risk_map <- ggplot_gtable(mexico_risk_map) %>%
  wrap_ggplot_grob()
NAmerica_patchwork <- (
    canada_risk_plot + plot_spacer() + canada_risk_map +
    mexico_risk_plot + plot_spacer() + mexico_risk_map
  ) +
  # annotation
  plot_annotation(
    title = "Risk shift in regions of future interest for viticulture",
    subtitle = "North America"
    ) +
  plot_layout(ncol = 3, nrow = 2, widths = unit(c(5.5, 1, 5.5), "cm"), heights = unit(5.5, "cm"))
ggsave(
  NAmerica_patchwork, 
  filename = file.path(here::here(), "vignette-outputs", "figures", "future_viticultural_regions_north_america.jpg"),
  height = 8, 
  width = 8,
  device = jpeg,
  dpi = "retina"
  )

Viticultural regions of interest- West Asia

# türkiye
türkiye_risk_plot <- türkiye_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "A") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )

# edits
# remove geom_text
türkiye_risk_plot <- türkiye_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
türkiye_risk_plot$data[[4]]$size <- 1.5
türkiye_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#türkiye_risk_plot$data[[3]]$linewidth <- 0.1

türkiye_risk_plot <- ggplot_gtable(türkiye_risk_plot) %>%
  wrap_ggplot_grob()



# georgia
georgia_risk_plot <- georgia_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "C") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )

# edits
# remove geom_text
georgia_risk_plot <- georgia_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
georgia_risk_plot$data[[4]]$size <- 1.5
georgia_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#georgia_risk_plot$data[[3]]$linewidth <- 0.1

georgia_risk_plot <- ggplot_gtable(georgia_risk_plot) %>%
  wrap_ggplot_grob()


# edit maps
# türkiye
türkiye_risk_map <- türkiye_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "B") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(0.1, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )


türkiye_risk_map <- ggplot_build(türkiye_risk_map)
# edit point size
türkiye_risk_map$data[[3]]$size <- 1.5

türkiye_risk_map <- ggplot_gtable(türkiye_risk_map) %>%
  wrap_ggplot_grob()


# georgia
georgia_risk_map <- georgia_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "D") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(0.1, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )


georgia_risk_map <- ggplot_build(georgia_risk_map)
# edit point size
georgia_risk_map$data[[3]]$size <- 1.5

georgia_risk_map <- ggplot_gtable(georgia_risk_map) %>%
  wrap_ggplot_grob()
west_asia_patchwork <- (
    türkiye_risk_plot + plot_spacer() + türkiye_risk_map +
    georgia_risk_plot + plot_spacer() + georgia_risk_map
  ) +
  # annotation
  plot_annotation(
    title = "Risk shift in regions of future interest for viticulture",
    subtitle = "Western Asia"
    ) +
  plot_layout(ncol = 3, nrow = 2, widths = unit(c(5.5, 1, 5.5), "cm"), heights = unit(5.5, "cm"))
ggsave(
  west_asia_patchwork, 
  filename = file.path(here::here(), "vignette-outputs", "figures", "future_viticultural_regions_west_asia.jpg"),
  height = 8, 
  width = 8,
  device = jpeg,
  dpi = "retina"
  )

Viticultural regions of interest- East Asia

# china
china_risk_plot <- china_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "A") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )

# edits
# remove geom_text
china_risk_plot <- china_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
china_risk_plot$data[[4]]$size <- 1.5
china_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#china_risk_plot$data[[3]]$linewidth <- 0.1

china_risk_plot <- ggplot_gtable(china_risk_plot) %>%
  wrap_ggplot_grob()


# south_korea
south_korea_risk_plot <- south_korea_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "C") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )

# edits
# remove geom_text
south_korea_risk_plot <- south_korea_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
south_korea_risk_plot$data[[4]]$size <- 1.5
south_korea_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#south_korea_risk_plot$data[[3]]$linewidth <- 0.1

south_korea_risk_plot <- ggplot_gtable(south_korea_risk_plot) %>%
  wrap_ggplot_grob()



# japan
japan_risk_plot <- japan_slf_risk_report[["viticultural_risk_plot"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "E") +
  theme(
    legend.position = "none", 
    panel.border = element_rect(size = 1, linetype = "solid", color = "black"), 
    plot.tag.position = c(0.2, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )

japan_risk_plot <- japan_risk_plot %>%
  gginnards::delete_layers(match_type = "GeomLabel") %>%
  ggplot_build()
# edit point size
japan_risk_plot$data[[4]]$size <- 1.5
japan_risk_plot$data[[5]]$size <- 1.5
# edit linewidth
#japan_risk_plot$data[[3]]$linewidth <- 0.1

japan_risk_plot <- ggplot_gtable(japan_risk_plot) %>%
  wrap_ggplot_grob()


  # edit maps
# new zealand
china_risk_map <- china_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "B") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(-0.1, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )


china_risk_map <- ggplot_build(china_risk_map)
# edit point size
china_risk_map$data[[3]]$size <- 1.5

china_risk_map <- ggplot_gtable(china_risk_map) %>%
  wrap_ggplot_grob()



# south_korea
south_korea_risk_map <- south_korea_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "D") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(-0.1, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )


south_korea_risk_map <- ggplot_build(south_korea_risk_map)
# edit point size
south_korea_risk_map$data[[3]]$size <- 1.5

south_korea_risk_map <- ggplot_gtable(south_korea_risk_map) %>%
  wrap_ggplot_grob()


# japan
japan_risk_map <- japan_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank()
    ) +
  labs(tag = "F") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(-0.1, 0.9),
    plot.tag = element_text(face = "bold", size = 20)
    )
  
japan_risk_map <- ggplot_build(japan_risk_map)
# edit point size
japan_risk_map$data[[3]]$size <- 1.5
# rebuild plot
japan_risk_map <- ggplot_gtable(japan_risk_map) %>%
  wrap_ggplot_grob()
east_asia_patchwork <- (
  # china top row
  china_risk_plot + plot_spacer() + china_risk_map + 
  # south_korea
  south_korea_risk_plot + plot_spacer() + south_korea_risk_map +
  # japan bottom row
  japan_risk_plot + plot_spacer() + japan_risk_map
  ) +
  # annotation
  plot_annotation(
    title = "Risk shift in regions of future interest for viticulture",
    subtitle = "Eastern Asia"
    ) +
  plot_layout(ncol = 3, nrow = 3, widths = unit(c(5.5, 1, 5.5), "cm"), heights = unit(5.5, "cm"))
ggsave(
  east_asia_patchwork, 
  filename = file.path(here::here(), "vignette-outputs", "figures", "future_viticultural_regions_east_asia.jpg"),
  height = 10, 
  width = 8,
  device = jpeg,
  dpi = "retina"
  )

Patchwork USA maps

USA_risk_map_present <-  united_states_slf_risk_report[["risk_maps"]][["present_risk_map"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "Present") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(0.15, 0.20),
    plot.tag = element_text(face = "bold", size = 20)
    ) +
  xlim(-125, -65) +
  ylim(25, 50)

USA_risk_map_present <- ggplot_build(USA_risk_map_present)
# edit point size
USA_risk_map_present$data[[3]]$size <- 1.5

USA_risk_map_present <- ggplot_gtable(USA_risk_map_present) %>%
  wrap_ggplot_grob()
 


USA_risk_map_future <-  united_states_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "Future") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(0.15, 0.2),
    plot.tag = element_text(face = "bold", size = 20)
    ) +
  xlim(-125, -65) +
  ylim(25, 50)

USA_risk_map_future <- ggplot_build(USA_risk_map_future)
# edit point size
USA_risk_map_future$data[[3]]$size <- 1.5

USA_risk_map_future <- ggplot_gtable(USA_risk_map_future) %>%
  wrap_ggplot_grob()
USA_patchwork <- (
  # romania top row
  USA_risk_map_present / USA_risk_map_future 
  ) +
  # annotation
  plot_annotation(title = "USA risk maps") 
ggsave(
  USA_patchwork, 
  filename = file.path(here::here(), "vignette-outputs", "figures", "USA_risk_maps.jpg"),
  height = 10, 
  width = 8,
  device = jpeg,
  dpi = "retina"
  )

Patchwork washington maps

WA_risk_map_present <-  washington_slf_risk_report[["risk_maps"]][["present_risk_map"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "Present") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(0.15, 0.15),
    plot.tag = element_text(face = "bold", size = 20)
    ) 

WA_risk_map_present <- ggplot_build(WA_risk_map_present)
# edit point size
WA_risk_map_present$data[[3]]$size <- 1.5

WA_risk_map_present <- ggplot_gtable(WA_risk_map_present) %>%
  wrap_ggplot_grob()
 


WA_risk_map_future <-  washington_slf_risk_report[["risk_maps"]][["2041-2070_risk_map"]] +
  theme(
    plot.title = element_blank(),
    plot.subtitle = element_blank(),
    plot.caption = element_blank(),
    axis.title = element_blank()
    ) +
  labs(tag = "Future") +
  theme(
    legend.position = "none", 
    plot.tag.position = c(0.15, 0.15),
    plot.tag = element_text(face = "bold", size = 20)
    )

WA_risk_map_future <- ggplot_build(WA_risk_map_future)
# edit point size
WA_risk_map_future$data[[3]]$size <- 1.5

WA_risk_map_future <- ggplot_gtable(WA_risk_map_future) %>%
  wrap_ggplot_grob()
WA_patchwork <- (
  # romania top row
  WA_risk_map_present / WA_risk_map_future 
  ) +
  # annotation
  plot_annotation(title = "washington risk maps") 
ggsave(
  WA_patchwork, 
  filename = file.path(here::here(), "vignette-outputs", "figures", "washington_risk_maps.jpg"),
  height = 10, 
  width = 8,
  device = jpeg,
  dpi = "retina"
  )