Skip to contents

floodam.agri produces flood damage functions for crops from in-depth expert knowledge on crop vulnerability to hazard parameters (velocity, height, duration and seasonality). This tool has been used to build the french national damage functions to the agricultural sector (@AgenaisAL2013a, @BremondP2022a) which can be downloaded here: www.ecologie.gouv.fr.

This vignette provides the steps to build the french national damage functions.

Declaring paths

The process starts by providing the input and output directories with init_path(). To make things easier, floodam.agri is shipped with the inputs for building the french national damage functions. These inputs are available in your library’s installation folder under the name national. You will also need to provide a folder where the output of floodam.agri can be stored (our example uses a temporary directory):

#> Loading required package: floodam.agri
library(floodam.agri)

#> Setting up environment paths (inputs and outputs)
input = stats::setNames(
    system.file(
      "extdata",
      "national",
      "2009-2010-2011",
      package = "floodam.agri"
    ),
    "national"
)
output = file.path(tempdir(), "national")
classification = system.file(
  "extdata",
  "classification",
  package = "floodam.agri"
)

path = init_path(
  input = input,
  output = output,
  default = TRUE,
  classification = classification
)

Preparing data

The purpose of this step is to prepare data needed to build the damage functions and store them in the output folder. This helps keep track of which inputs were used for each simulation. The functions to be called are the following: prepare_culture(), prepare_calendar(), prepare_typology() and prepare_action_value().

Run the chunk below to prepare data needed for building the damage functions.

#> Extracting damagement files to output
prepare_culture(path)

#> Extracting and copying calendars to output
prepare_calendar(path)

#> Building weight files
prepare_typology(
  path,
  "RPG" # name of the classification used to build weights.
        # See `path[["classification"]][["RPG.csv"]]`
)

#> Preparing necessary action values and yields
prepare_action_value(path)

Feel free to take a look at the prepared data in the output directory.

Building damage functions

The function calculate_damaging() builds damage functions for the crops specified in the argument culture. If culture is set to NULL, damage functions are built for all the crops that have been prepared in the previous step in path[["output"]][["culture"]]. For the purpose of our example, we will limit the number of damage functions built to the following crops: “onion”, “salad”, “vineyard” and “wheat”.

#> Calculating damage function
damaging = calculate_damaging(
  path,
  culture = # set to NULL to build all damage functions
    c("onion", "salad", "vineyard", "wheat"),
  retrieve = TRUE
)
#> Update of culture damaging functions:
#>   Processing onion... Finished in 3.39 secs
#>   Processing salad... Finished in 3.99 secs
#>   Processing vineyard... Finished in 4.78 secs
#>   Processing wheat... Finished in 3.40 secs
#> ... processed in 12.17 secs

Congratulations, you have built your first damage functions !

They are stored in path[["output"]][["damage"]]. By default, three data.frames for each crop are saved:

  • full/damage_crop.csv
    • TO BE PRECISED (damage function and associated damaging rules)
  • sumup/damage_crop.csv
    • total damage function
  • sumup/damage-disaggregated_crop.csv
    • total and disaggregated (yield, replanting, soil and material) damage function

As you can see in the table below which shows the disaggregated result of calculate_damaging() for a vineyard plot, the produced damage functions do not have any hazard parameters in them. The hazard parameters associated to each row of these data.frames are available in the data.frame file.path(path[["output"]][["damage"]], "hazard.csv")

Disaggregated result of calculate_damaging()

Combine damage functions

This step has the main purpose of associating the produced damage functions together with the correct hazard parameters. In some cases, the combination of damage functions can be made in order to transform the floodam.agri classification to another. In our example, we transform the floodam raw functions to the french Land Parcel Identification System (LPIS) classification called “Registre Parcellaire Graphique” (RPG).

#> Combine damage to new classification
combine = combine_damaging(
  path = path,
  damage.culture = damaging,
  weight = "RPG",
  verbose = TRUE,
  retrieve = "total" # one of c("total", "yield.annual", "yield.differed",
  # "replanting", "soil", material")
)

combine_damaging() exports one combined damage curve for each damage type c( "total", "yield.annual", "yield.differed","replanting", "soil", material"). They can be found in the following output folder : path[["output"]][["combine"]]

In the table below is a glimpse of what the combine object is: combined damage functions of “total” damage for all crops selected in simulation and their associated hazard parameters.

Aggregating the damage functions

To simplify the result of combine_damaging(), the raw damage functions can be aggregated by regrouping hazard parameters into classes by using the aggregate_damage() function. The official french national damage functions are aggregated by season (winter, spring, summer, autumn), velocity (light, middle, strong) and duration (short, middle, long, extra).

The correspondance between each hazard parameter class and their values is loaded by default from three files located in the folder file.path(path[["default"]][["hazard"]], "hazard.00") shown in the tables below.

Velocity
min max
light 1 1
middle 2 2
strong 3 3
Duration
min max
short 0 1
middle 2 4
long 5 10
extra 11 20
Seasonality
min max
spring 14 26
summer 27 39
autumn 40 52
winter 1 13

Hazard parameters classes used in the french national damage functions.

Run the chunk below to transform the raw damage functions to the official french national damage functions to the agricultural sector.

#> Aggregation of damage according to the specified `hazard.00` parameters
agg_damaging = aggregate_damage(
    path,
    damage_origin = "RPG_total", # by default
    hazard_agg = "hazard.00" # by default
)

The table below shows the output of aggregate_damage(). Two main elements have changed:

  • damage functions have been weighted accordingly to the hazard_agg parameter.
  • floodam crops have been weighted to fit the RPG classification.
    • for example, “onion” and “salad” have been passed to “LEGUMES - FLEURS”. In reality, there are more crops included in the “LEGUMES - FLEURS” category but for simplicity, we did not add all of them in our example.

Congratulations ! You have managed to reproduce a part of the national french damage functions to the agricultural sector. Feel free to run this code again and build the damage functions for all crops by setting the culture argument of calculate_damaging() to NULL.

Learn more

More vignettes are to come. Stay alert !

References