Skip to contents

This function prepares a user soil table for the SWAT model based on the provided CSV file.

Usage

get_usersoil_table(csv_path, hsg = FALSE, keep_values = FALSE, nb_lyr = NA)

Arguments

csv_path

Character path to the CSV file (e.g., "usersoil_lrew.csv"). The file should be comma-separated with minimum columns of:

  • SNAM - name of soil type,

  • NLAYERS - number of soil layers in the soil, and for each soil layer i (minimum 1).

  • SOL_Zi - depth from soil surface to bottom of layer in mm;

  • CLAYi - clay content (particles <0.002 mm) in % soil weight;

  • SILTi - silt content (particles between 0.002 and 0.05 mm) in % soil weight;

  • SANDi - sand content (particles between 0.05 and 2 mm) in % soil weight;

  • SOL_CBNi - organic carbon content (% soil weight) for each available soil layer.

hsg

(optional) Logical, TRUE - prepare soil hydrological groups, FALSE - no soil hydrological group preparation will be done. Default hsg = FALSE. If hsg = TRUE, three additional columns should be in an input table:

  • 'Impervious' - depth to water impermeable layer (allowed values are "<50cm", "50-100cm", ">100cm");

  • 'Depth' - depth to high water table (allowed values are "<60cm", "60-100cm", ">100cm");

  • 'Drained' - information on tile drains (allowed values are "Y" for drained areas, "N" for areas without working tile drains).
    More information can be found in the SWAT+ modeling protocol Table 3.3.

keep_values

(optional) Logical or character vector, TRUE - keep original values (only 0 or NA values of the original input table are overwritten with the values computed by the function, else original values are kept), FALSE - all original values are overwritten with the values computed by the function.

If a character vector is provided, it should contain names of columns to keep. For instance, c("HYDGRP", "ROCK1") would keep values of soil hydrologic groups and rock content data of the first layer, while c("HYDGRP", "ROCK") would keep values of soil hydrologic groups and rock content data of all soil layers.
Default keep_values = FALSE.

nb_lyr

(optional) Integer, the number of layers resulting user soil data should contain. Default nb_lyr = NA, which stands for the same number as in the input data.

Value

A dataframe with a fully formatted and filled table of soil parameters for the SWAT model.

References

SWAT+ Modeling Protocol: Soil Physical Data Chapter

This function utilizes the PTF functions and methods described in pages 82-91. For detailed information, refer to: https://doi.org/10.5281/zenodo.7463395

See also

This function requires the euptf2 package. Please read information on its installation and description on https://github.com/tkdweber/euptf2.

Examples

if (FALSE) {
  usersoils <- get_usersoil_table("table.csv")
  write.csv(usersoils, "usersoils.csv", row.names=FALSE, quote=FALSE)
}