Prepare data from raw to form needed for calculating the index. See the NatureServe Guidelines for details on how the data is prepared.

prep_clim_data(
  mat_norm,
  mat_fut,
  cmd_norm,
  cmd_fut,
  ccei = NULL,
  map = NULL,
  mwmt = NULL,
  mcmt = NULL,
  clim_poly = NULL,
  in_folder = NULL,
  out_folder,
  reproject = FALSE,
  overwrite = FALSE,
  scenario_name = "",
  brks_mat = NULL,
  brks_cmd = NULL,
  brks_ccei = NULL
)

Arguments

mat_norm, mat_fut, cmd_norm, cmd_fut, ccei, map, mwmt, mcmt, clim_poly

file paths to find data if in_folder is not given

in_folder

file path where files are stored. Files must be named according to the convention described in details

out_folder

file path where the processed files will be saved

reproject

should the data be re-projected to lat/long? Not recommended.

overwrite

should existing files in out_folder be overwritten?

scenario_name

a string identifying the climate change scenario that will be used as a suffix for the output files.

brks_mat, brks_cmd, brks_ccei

a matrix containing breaks to use for classifying mat, cmd and ccei into 6, 6 and 4 classes, respectively. See reclassify for details on the matrix format. If NULL, the default, the breaks will be determined using the median and half the interquartile range

Value

Returns a list of matrices with the breaks used to classify mat, cmd and ccei. This list can be supplied to a future call to prep_clim_data in order to use the same breaks for multiple climate data sets. Processed data is saved in out_folder

Details

Definition of input data sets and file names required in in_folder:

mat_norm:

"MAT" mean annual temperature for the historical normal period

mat_fut:

"MAT_2050" mean annual temperature for the future under climate change it can be any number eg 2050, 2100

cmd_norm:

"CMD" climate moisture deficit for the historical normal period

cmd_fut:

"CMD_2050" climate moisture deficit for the future under climate change it can be any number eg 2050, 2100

ccei:

"CCEI" Climate Change Exposure Index from NatureServe website

map:

"MAP" mean annual precipitation for the historical normal period

mwmt:

"MWMT" mean warmest month temperature for the historical normal period

mcmt:

"MCMT" mean coldest month temperature for the historical normal period

clim_poly:

An optional shapefile with a polygon of the range of the climate data. It will be created from the climate data if it is missing but it is faster to provide it.

Accepted raster file types are ".asc", ".tif", ".nc", ".grd" and ".img"

See also

get_clim_vars for loading the processed data.

Examples

in_folder <- system.file("extdata/clim_files/raw", package = "ccviR")

pth_out <- system.file("extdata/clim_files/processed", package = "ccviR")

# use first scenario to set breaks
brks_out <- prep_clim_data(mat_norm = file.path(in_folder, "NB_norm_MAT.tif"),
                           mat_fut = file.path(in_folder, "NB_RCP.4.5_MAT.tif"),
                           cmd_norm = file.path(in_folder, "NB_norm_CMD.tif"),
                           cmd_fut = file.path(in_folder, "NB_RCP.4.5_CMD.tif"),
                           map = file.path(in_folder, "NB_norm_MAP.tif"),
                           mwmt = file.path(in_folder, "NB_norm_MWMT.tif"),
                           mcmt = file.path(in_folder, "NB_norm_MCMT.tif"),
                           out_folder = pth_out,
                           clim_poly = file.path(system.file("extdata", package = "ccviR"),
                                                 "assess_poly.shp"),
                           overwrite = TRUE,
                           scenario_name = "RCP 4.5")
#> processing MAT
#> processing CMD
#> processing MAP
#> processing MWMT and MCMT
#> finished processing

prep_clim_data(mat_norm = file.path(in_folder, "NB_norm_MAT.tif"),
               mat_fut = file.path(in_folder, "NB_RCP.8.5_MAT.tif"),
               cmd_norm = file.path(in_folder, "NB_norm_CMD.tif"),
               cmd_fut = file.path(in_folder, "NB_RCP.8.5_CMD.tif"),
               out_folder = pth_out,
               clim_poly = file.path(system.file("extdata", package = "ccviR"),
                                     "assess_poly.shp"),
               overwrite = TRUE,
               scenario_name = "RCP 8.5",
               brks_mat = brks_out$brks_mat, brks_cmd = brks_out$brks_cmd,
               brks_ccei = brks_out$brks_ccei)
#> processing MAT
#> processing CMD
#> finished processing