Skip to contents

This function creates a report at the country or state/province level for the risk of establishment of Lycorma delicatula. The report covers the major data outputs from this R package analysis, including current and future risk maps, range shift maps, risk plots and risk tables.

Usage

create_risk_report(
  locality.iso,
  locality.name = locality.iso,
  locality.type,
  save.report = FALSE,
  mypath = NA,
  raster.path = file.path(here::here(), "vignette-outputs", "rasters"),
  create.dir = FALSE,
  map.style = NA,
  buffer.dist = NA
)

Arguments

locality.iso

The alpha-3 ISO code corresponding to the country of interest. If the desired locality is a state or province, please still enter the ISO code and supply the name of that province in locality.name.

locality.name

The name of the country, state or province for which to generate the report. This is optional if the report is for a country, but required if the report is for a state/province. Avoid special characters, but please include those used used in the ethnic naming (ex: Côte d'Ivoire).

locality.type

One of "country" or "state_province". If you do not know the state or province you are looking for, you might create a report at the country level and then look at the return for the name of the state/province included.

save.report

Logical. Should the report be saved to file? File location specified by mypath. Note, this requires the use of Google Chrome.

mypath

Character. Only required if saving the report to file. A file path to the sub directory where the model output will be stored. Should be used with the file.path() function (i.e. with '/' instead of '\'). If this sub directory does not already exist and should be created by the function, set create.dir = TRUE. This will create a folder from the last part of the filepath in mypath.

raster.path

Character. A file path to the directory containing the rasters necessary to build this function. See details for the rasters that should be included with this data input and for the default path.

create.dir

Logical. Should the last element of mypath create a sub directory for the report? If TRUE, the main folder will be created for the model output. If FALSE (ie, the sub directory already exists), no directory will be created.

map.style

List. This is used to apply ggplot aesthetics to the mapped outputs. If specified, the given value should be a list of ggplot aesthetic options. If not, the built-in default list will be used (see details). See examples for usage.

buffer.dist

Numeric. The distance (in meters) from each IVR coordinate at which to draw buffers zones on risk maps. Should be the same distance that was used to calculate the predicted suitability for each IVR region. See predict.xy.suitability.R for details. If not specified, buffers are not drawn and suitabiltiy prediction method is assumed to be simple (point-wise).

Value

returns a report in list format. If save.report = TRUE, will also save the report to file at destination specified by mypath. The outputs returned to the global env in a list object include:

  • viticultural_regions_list - a list of known important wine regions within the locality with predicted suitability values and levels.

  • risk_maps - a current and future map of risk for L delicatula establishment. The CMIP6 predictions are based on the mean of the three ssp scenarios

  • viticultural_risk_plot = a quantified assessment of the risk for L delicatula establishment for known wine regions within the locality. This plot depicts the intersection of our two modeled scales.

  • viticultural_risk_table = a risk table quantifying the level of risk to vineyards according to the quadrant plot

  • range_shift_map = a map of potential range expansion for L delicatula under climate change

Some maps may be formatted strangely because of a country's outlying territories. You may need to further crop the plot using xlim() and ylim() (see examples).

Use caution, this function will overwrite previous files output for the same locality.

Details

Requires the following packages: 'tidyverse', 'terra', 'here', 'cli', 'rnaturalearth', 'rnaturalearthhires', 'kableExtra', 'formattable', 'webshot', 'webshot2', 'ggnewscale', 'common'. NOTE This function requires the use of Google Chrome if save.report = TRUE

Note that this function performs downloads from naturalearthdata.com, if the data do not already exist in root/data-raw.The function will automatically create subfolders in root/data-raw containing the downloaded shapefiles.

This function depends on certain files that have been distributed with this package, which will be imported from root/R/sysdata.rda when the function is run. The code to create sysdata.rda can be found in root/vignettes/160_generate_risk_report.Rmd.

Here is a list of the files included in sysdata.rda:

  • global_model_summary.rds | created in vignette 050

  • ensemble_thresh_values.rds | created in vignette 110

  • wineries_tidied.rds | created in vignette 130

  • regional_ensemble_wineries_1981-2010_xy_pred_suit.rds | created in vignette 130

  • regional_ensemble_wineries_2041-2070_GFDL_ssp_mean_xy_pred_suit.rds | created in vignette 130

  • global_wineries_1981-2010_xy_pred_suit.rds | created in vignette 130

  • global_wineries_2041-2070_GFDL_ssp_mean_xy_pred_suit.rds | created in vignette 130

Additionally, 3 rasters are used to create maps. These rasters are located in root/vignette-outputs/rasters, These are the files:

  • slf_binarized_summed_1981-2010.asc | created in vignette 120

  • slf_binarized_summed_2041-2070_ssp_mean_GFDL.asc | created in vignette 120

  • slf_range_shift_summed.asc | created in vignette 120

Additionally, root/vignette-outputs/rasters is the default path for the raster.path() argument.

Examples