Skip to contents

adapt_saa_floodam() processes the SAA annual agricultural statistical adapted data archive (typically the result of adapt_saa()) to prepare it for use with the floodam.agri model. It reads the archive, calculates missing yields, selects relevant variables, performs data cleaning, and saves the processed data in a specific format.

Usage

adapt_saa_floodam(
  origin,
  destination = tempdir(),
  archive,
  scope = c("departement", "region", "national"),
  extent,
  year,
  n_years = 1,
  verbose = TRUE
)

Arguments

origin

character, path to the directory where archive is stored.

destination

character, path to the directory where results should be saved. Default to tempdir().

archive

character, vector of archive to be adpated.

scope

character, scope of the data. One of c("departement", "region", "national")

extent

character, extent of the data, name of departement, region or national extent.

year

character, year of the data to process.

n_years

integer, number of years to extract. If set to 1, only the year in year will be extracted. If n_years > 1, n_years-1 years will be added to extraction. Default set to 1.

verbose

boolean, will floodam tell what it is doing, default to TRUE.

Value

This function saves the processed data to a file.

Examples

if (FALSE) { # \dontrun{
destination = tempdir()
download_saa(destination)
adapt_saa(
 origin = destination,
 destination = destination,
 scope = "departement"
)
adapt_saa_floodam(
  origin = destination,
  destination = destination,
  archive = "SAA_2010-2024_departement.csv",
  scope = "departement",
  extent = "H\u00E9rault",
  year = "2024",
  verbose = TRUE
)
} # }