Title: | Mediterranean Landscape Simulation |
---|---|
Description: | Simulate forest hydrology, forest function and dynamics over landscapes [De Caceres et al. (2015) <doi:10.1016/j.agrformet.2015.06.012>]. Parallelization is allowed in several simulation functions and simulations may be conducted including spatial processes such as lateral water transfer and seed dispersal. |
Authors: | Miquel De Cáceres [aut, cre], Aitor Améztegui [aut] , María González [aut] , Núria Aquilué [aut], Daniel Caviedes-Voullième [aut], Mario Morales-Hernández [aut], Mario Beltrán [ctb], Rodrigo Balaguer-Romano [ctb] , Roberto Molowny-Horas [ctb] |
Maintainer: | Miquel De Cáceres <[email protected]> |
License: | GPL (>= 2) |
Version: | 2.5.0 |
Built: | 2024-10-30 02:44:55 UTC |
Source: | https://github.com/emf-creaf/medfateland |
Creates and adds forest data to an sf
object by reading from tree and shrub data tables
add_forests( x, tree_table = NULL, tree_mapping = NULL, shrub_table = NULL, shrub_mapping = NULL, merge_trees = TRUE, merge_shrubs = TRUE, SpParams = NULL, progress = FALSE )
add_forests( x, tree_table = NULL, tree_mapping = NULL, shrub_table = NULL, shrub_mapping = NULL, merge_trees = TRUE, merge_shrubs = TRUE, SpParams = NULL, progress = FALSE )
x |
An object of class |
tree_table |
A data frame with tree records in rows and attributes in columns. Tree records can correspond to individual trees or groups of trees with an associated density. |
tree_mapping |
A named character vector to specify mappings of columns in
|
shrub_table |
A data frame with shrub records in rows and attributes in columns. Records can correspond to individual shrubs (with crown dimensions and height) or groups of shrubs with an associated cover estimate. |
shrub_mapping |
A named character vector to specify mappings of columns in
|
merge_trees |
A logical flag to simplify tree cohorts by merging tree records in DBH classes (see |
merge_shrubs |
A logical flag to simplify shrub cohorts by merging shrub records in height classes (see |
SpParams |
A data frame with species parameters (see |
progress |
A logical flag to include a progress bar while processing the data. |
The current implementation will replace existing forests of the indicated 'id' values.
A modified object of class sf
with column 'forest'.
Miquel De Cáceres Ainsa, CREAF
impute_forests()
, forest_mapWoodyTables
, forest_mergeTrees
# Load tree data data(poblet_trees) # Load species parameters data(SpParamsMED) # Define sf with three stands cc <- rbind(c(1.0215, 41.3432), c(1.0219, 41.3443), c(1.0219, 41.3443)) d <- data.frame(lon = cc[,1], lat = cc[,2], id = c("POBL_CTL", "POBL_THI_BEF", "POBL_THI_AFT")) x <- sf::st_as_sf(d, coords = c("lon", "lat"), crs = 4326) x # Define tree mapping mapping <- c("id" = "Plot.Code", "Species.name" = "Species", "DBH" = "Diameter.cm") # Read tree data (warnings are raised) y_1 <- add_forests(x, tree_table = poblet_trees, tree_mapping = mapping, SpParams = SpParamsMED) # Correct scientific name for downy oak and repeat to avoid losing tree records poblet_trees$Species[poblet_trees$Species=="Quercus humilis"] <- "Quercus pubescens" y_1 <- add_forests(x, tree_table = poblet_trees, tree_mapping = mapping, SpParams = SpParamsMED) # Display summary of first forest summary(y_1$forest[[1]], SpParamsMED) # Add sampled plot surface and repeat reading to correct tree density poblet_trees$PlotSurface <- 706.86 mapping <- c(mapping, "plot.size" = "PlotSurface") y_2 <- add_forests(x, tree_table = poblet_trees, tree_mapping = mapping, SpParams = SpParamsMED) summary(y_2$forest[[1]], SpParamsMED) # Check forests (height is missing!) check_forests(y_2) # Estimate tree height using general allometric poblet_trees$Height.cm <- 100 * 1.806*poblet_trees$Diameter.cm^0.518 #Modify mapping to include height and repeat mapping <- c(mapping, "Height" = "Height.cm") y_3 <- add_forests(x, tree_table = poblet_trees, tree_mapping = mapping, SpParams = SpParamsMED) summary(y_3$forest[[1]], SpParamsMED) # Final check check_forests(y_3)
# Load tree data data(poblet_trees) # Load species parameters data(SpParamsMED) # Define sf with three stands cc <- rbind(c(1.0215, 41.3432), c(1.0219, 41.3443), c(1.0219, 41.3443)) d <- data.frame(lon = cc[,1], lat = cc[,2], id = c("POBL_CTL", "POBL_THI_BEF", "POBL_THI_AFT")) x <- sf::st_as_sf(d, coords = c("lon", "lat"), crs = 4326) x # Define tree mapping mapping <- c("id" = "Plot.Code", "Species.name" = "Species", "DBH" = "Diameter.cm") # Read tree data (warnings are raised) y_1 <- add_forests(x, tree_table = poblet_trees, tree_mapping = mapping, SpParams = SpParamsMED) # Correct scientific name for downy oak and repeat to avoid losing tree records poblet_trees$Species[poblet_trees$Species=="Quercus humilis"] <- "Quercus pubescens" y_1 <- add_forests(x, tree_table = poblet_trees, tree_mapping = mapping, SpParams = SpParamsMED) # Display summary of first forest summary(y_1$forest[[1]], SpParamsMED) # Add sampled plot surface and repeat reading to correct tree density poblet_trees$PlotSurface <- 706.86 mapping <- c(mapping, "plot.size" = "PlotSurface") y_2 <- add_forests(x, tree_table = poblet_trees, tree_mapping = mapping, SpParams = SpParamsMED) summary(y_2$forest[[1]], SpParamsMED) # Check forests (height is missing!) check_forests(y_2) # Estimate tree height using general allometric poblet_trees$Height.cm <- 100 * 1.806*poblet_trees$Diameter.cm^0.518 #Modify mapping to include height and repeat mapping <- c(mapping, "Height" = "Height.cm") y_3 <- add_forests(x, tree_table = poblet_trees, tree_mapping = mapping, SpParams = SpParamsMED) summary(y_3$forest[[1]], SpParamsMED) # Final check check_forests(y_3)
Initializes topography and land cover type for a set of target locations
add_topography(x, dem, progress = TRUE) add_land_cover( x, land_cover_map, wildland = NULL, agriculture = NULL, rock = NULL, artificial = NULL, water = NULL, progress = TRUE )
add_topography(x, dem, progress = TRUE) add_land_cover( x, land_cover_map, wildland = NULL, agriculture = NULL, rock = NULL, artificial = NULL, water = NULL, progress = TRUE )
x |
An object of class |
dem |
A digital elevation model (class |
progress |
A logical flag to print console output |
land_cover_map |
An object of class |
wildland , agriculture , rock , artificial , water
|
Strings indicating the mapping from the legend of land_cover_map. |
The user should manually define the mapping of land cover classes in land_cover_map
to the land cover types
used in medfateland.
Function add_topography()
returns a modified object of class sf
with columns:
id
: Numeric location identifiers (if not existing).
elevation
: Elevation above sea level (in m).
slope
: Slope (in degrees).
aspect
: Aspect (in degrees).
land_cover_type
: Land cover type.
Function add_land_cover()
returns a modified object of class sf
with new column:
id
: Numeric location identifiers (if not existing).
land_cover_type
: Land cover type.
check_topography()
, check_land_cover()
# See package vignettes 'Preparing inputs'
# See package vignettes 'Preparing inputs'
Functions to check and correct spatial inputs for simulations
check_topography( x, missing_action = "no_action", default_values = c(elevation = 0, slope = NA, aspect = NA), verbose = TRUE ) check_land_cover( x, missing_action = "no_action", default_values = "wildland", verbose = TRUE ) check_forests( x, SpParams = NULL, missing_action = "no_action", progress = FALSE, verbose = TRUE ) check_soils( x, check_equal_layers = FALSE, missing_action = "no_action", default_values = c(clay = 25, sand = 25, bd = 1.5, rfc = 25), progress = FALSE, verbose = TRUE )
check_topography( x, missing_action = "no_action", default_values = c(elevation = 0, slope = NA, aspect = NA), verbose = TRUE ) check_land_cover( x, missing_action = "no_action", default_values = "wildland", verbose = TRUE ) check_forests( x, SpParams = NULL, missing_action = "no_action", progress = FALSE, verbose = TRUE ) check_soils( x, check_equal_layers = FALSE, missing_action = "no_action", default_values = c(clay = 25, sand = 25, bd = 1.5, rfc = 25), progress = FALSE, verbose = TRUE )
x |
An object of class |
missing_action |
Action to perform for missing values, either "no_action" (for checks), "filter" (filter missing data), "default" (impute default values) |
default_values |
Vector of default values for locations with missing data. |
verbose |
Logical flag to indicate extra console output. |
SpParams |
A data frame with species parameters (see |
progress |
A logical flag to print information about progress. |
check_equal_layers |
Logical flag to test whether soils have the same number of layers. |
Function check_topography()
checks that columns "elevation"
, "slope"
and "aspect"
do not contain missing values.
Function check_land_cover()
checks that column "land_cover_type"
does not contain missing values.
Function check_forests()
checks first that forest
objects are defined in "wildland" locations. Then, it looks for missing
data in tree or shrub attributes required for simulations. If SpParams
is provided, the function also checks
whether species names are within the taxa represented in SpParams
.
Function check_soils()
checks first that "wildland" and "agriculture" locations have a defined soil object. Then it looks for missing data in required
soil physical parameters.
All functions return a modified sf
object if missing_action
is either "filter"
or "default"
. Otherwise,
they return an invisible tibble with logical columns indicating where missing information is.
data(example_ifn) check_topography(example_ifn) check_land_cover(example_ifn) check_forests(example_ifn) check_soils(example_ifn)
data(example_ifn) check_topography(example_ifn) check_land_cover(example_ifn) check_forests(example_ifn) check_soils(example_ifn)
Defines an object containing fire regime parameters for simulations of forest dynamics.
create_fire_regime(annual_burned_area, sd_burned_area = NULL, doy = NULL)
create_fire_regime(annual_burned_area, sd_burned_area = NULL, doy = NULL)
annual_burned_area |
A named vector of burned area in hectares for simulation years. |
sd_burned_area |
A named vector of standard deviation (in log scale) of burned area. If specified, annual target to burn will be determined
using a log-normal distribution with mean values given by |
doy |
A named integer vector with the day of the year (i.e. between 1 and 366) when fires will be simulated for each simulation year in |
Names of annual_burned_area
should be simulation years. If provided, sd_burned_area
should be a vector of the same size as
annual_burned_area
and have the same names.
A list with the supplied parameters
Miquel De Cáceres Ainsa, CREAF
fire_regime_instance
, fordyn_scenario
, fordyn_spatial
# Fire regime with pre-defined burned area values reg1 <- create_fire_regime(annual_burned_area = c("2002" = 1000, "2003" = 5000)) # Fire regime with log-normal distribution for burned area reg2 <- create_fire_regime(annual_burned_area = c("2002" = 1000, "2003" = 5000), sd_burned_area = c("2002" = 0.9, "2003" = 0.8))
# Fire regime with pre-defined burned area values reg1 <- create_fire_regime(annual_burned_area = c("2002" = 1000, "2003" = 5000)) # Fire regime with log-normal distribution for burned area reg2 <- create_fire_regime(annual_burned_area = c("2002" = 1000, "2003" = 5000), sd_burned_area = c("2002" = 0.9, "2003" = 0.8))
Defines a management scenario for simulations of forest dynamics
create_management_scenario( units, annual_demand_by_species = NULL, extraction_rate_by_year = NULL, default_management_arguments = NULL )
create_management_scenario( units, annual_demand_by_species = NULL, extraction_rate_by_year = NULL, default_management_arguments = NULL )
units |
Number of management units. Alternatively, a data frame with management options (in columns) for a set of units (in rows). Options not specified witl be taken from defaults. |
annual_demand_by_species |
A vector or matrix of annual wood demand (m3) by medfate species names (or groups of species names). If empty, the scenario is 'bottom-up' (not based on demand). If a vector is supplied, the same wood demand is applied for all simulated years. If a matrix is supplied, each row should correspond to a different year. |
extraction_rate_by_year |
A vector of extraction rates (%) per year of the simulation, starting at the second year. If specified, the annual demand by species will be applied for the first year of the simulation, but it will be rescaled for the remaining years according to the growth observed and the desired extraction rates. |
default_management_arguments |
A list of arguments to be passed to the managementFunction. These arguments will be taken as defaults
copied for all management units and can later be modified. If NULL, the result of calling function
|
Three kinds of management scenarios are allowed:
'bottom-up'
represents a scenario where forest stands belong to different management units,
each of them having possibly distinct management prescriptions. However, there is no demand and the amount
of extracted wood emerges from the interplay between forest dynamics and management prescriptions.
'input_demand'
represents a scenario where a certain amount of wood extraction is targeted for some species
and each year. This requires deciding which stands will actually undergo thinning operations to fulfill the demand (stands
managed following prescriptions that indicate final regeneration cuts are managed irrespective of demand).
'input_rate'
represents a scenario similar to the previous one but where total amount of wood targeted depends
on (i.e. is a proportion of) the growth observed in previous year.
The kind of management scenario depends on the arguments supplied by the user when calling create_management_scenario
(see examples).
In all cases, management units need to be defined. Each management unit represents a group of forest stands
following the same management prescriptions. Although the create_management_scenario
function allows specifying the management arguments of each unit,
the simulation of management scenarios also requires specifying, for each forest stand, to which management unit it belongs (see fordyn_scenario
).
A list with the following structure:
scenario_type
: Either 'bottom-up' (no demand is specified),
'input_demand' (annual species demand is specified), or
'input_rate' when extraction rates are also supplied.
annual_demand_by_species
: A vector of annual wood demand (m3) by species (or species groups)
(for scenario_type 'bottom-up' or 'input_demand').
extraction_rate_by_year
: A vector of extraction rate values per year.
units
: A data frame with as many rows as units and management arguments as columns.
Miquel De Cáceres Ainsa, CREAF
Aitor Améztegui, UdL
fordyn_scenario
, defaultManagementFunction
, defaultPrescriptionsBySpecies
, create_fire_regime
# A scenario with three management units and annual demand for two species scen_1 <- create_management_scenario(3, c("Quercus ilex" = 1000, "Pinus nigra" = 2000)) # A scenario like the former, but with total annual demand changing as a function of # prescribed extraction rates (second and third years) scen_2 <- create_management_scenario(3, c("Quercus ilex" = 1000, "Pinus nigra" = 2000), c("2002" = 30, "2003" = 50)) # A scenario with as many management units as rows in 'defaultPrescriptionsBySpecies' # and not based on demand data("defaultPrescriptionsBySpecies") scen_3 <- create_management_scenario(defaultPrescriptionsBySpecies) # A scenario with three management units and annual demand for one species group # and a third species scen_4 <- create_management_scenario(3, c("Quercus ilex/Quercus pubescens" = 1000, "Pinus nigra" = 2000))
# A scenario with three management units and annual demand for two species scen_1 <- create_management_scenario(3, c("Quercus ilex" = 1000, "Pinus nigra" = 2000)) # A scenario like the former, but with total annual demand changing as a function of # prescribed extraction rates (second and third years) scen_2 <- create_management_scenario(3, c("Quercus ilex" = 1000, "Pinus nigra" = 2000), c("2002" = 30, "2003" = 50)) # A scenario with as many management units as rows in 'defaultPrescriptionsBySpecies' # and not based on demand data("defaultPrescriptionsBySpecies") scen_3 <- create_management_scenario(defaultPrescriptionsBySpecies) # A scenario with three management units and annual demand for one species group # and a third species scen_4 <- create_management_scenario(3, c("Quercus ilex/Quercus pubescens" = 1000, "Pinus nigra" = 2000))
Defines default control parameters for dispersal process
default_dispersal_control()
default_dispersal_control()
A list with the following items:
distance_step [= 25]
: Distance step in meters.
maximum_dispersal_distance [= 3000]
: Maximum dispersal distance in meters.
min_percent [= 1]
: A minimum percent of seed bank to retain entry in seedBank
element of forest
.
stochastic_resampling [= FALSE]
: A flag to indicate that stochastic resampling of stands is performed.
Miquel De Cáceres Ainsa, CREAF
spwb_land
, fordyn_scenario
dispersal
default_dispersal_control()
default_dispersal_control()
Example function for estimating wood volume (in m3/ha) from a tree table or forest object.
default_volume_function(x, SpParams = NULL)
default_volume_function(x, SpParams = NULL)
x |
A data frame with columns 'DBH', 'Height' and 'N' or a |
SpParams |
A data frame with species parameters (not used in the default function but will be called) |
Users should define their own functions taking into account that:
Input should be named 'x' and consist of a tree table with tree records as rows and columns 'DBH' (cm), 'Height' (cm), and 'N' (ind./ha).
Output should be a numeric vector of length equal to the number of tree records in 'x'
A function amenable for wood volume estimation.
Defines default control parameters for watershed processes
default_watershed_control(watershed_model = "tetis")
default_watershed_control(watershed_model = "tetis")
watershed_model |
Hydrological model for watershed processes. Only "tetis" or "serghei" are accepted. |
A list with the following items:
watershed_model
: A string with the watershed model.
weather_aggregation_factor [= 1]
: An integer specifying the spatial aggregation for interpolated weather.
tetis_parameters
: A list of TETIS parameters with the following elements:
R_localflow [= 1.0]
: Correction factor for soil hydraulic saturated conductivity (local vertical flows).
R_interflow [= 50.0]
: Correction factor for soil hydraulic saturated conductivity (subsurface flow between grid cells).
R_baseflow [= 5.0]
: Correction factor for bedrock hydraulic conductivity (groundwaterflow between grid cells).
n_interflow [= 1.0]
: Exponent for the determination of interflow.
n_baseflow [= 1.0]
: Exponent for the determination of baseflow.
num_daily_substeps [= 4]
: Number of daily sub-steps for interflow calculations.
rock_max_infiltration [= 10]
: Maximum infiltration rate (mm·day-1) for rock cells.
deep_aquifer_loss [= 0]
: Daily loss rate from watershed aquifer towards a deeper aquifer not connected to outlets (mm·day-1).
serghei_parameters
: A list of SERGHEI parameters with the following elements:
input_dir [= ""]
: Path to SERGHEI input files.
output_dir [= ""]
: Path to SERGHEI output files.
force_equal_layer_widths [= FALSE]
: A boolean flag to force equal layer widths (taken from the first soil element) in all soils.
Miquel De Cáceres Ainsa, CREAF
default_watershed_control()
default_watershed_control()
Default management prescriptions by species, defined according current practices in Catalonia (NE Spain)
A data frame with 27 species (or species groups) in rows and management parameters in columns (defined in defaultManagementArguments
)
Mario Beltrán & Míriam Piqué. Forest Science and Technology Centre of Catalonia (CTFC)
create_management_scenario
, defaultManagementArguments
,
fordyn_scenario
Simulates seed bank mortality, seed production and dispersal among stands
dispersal( sf, SpParams, local_control = medfate::defaultControl(), distance_step = 25, maximum_dispersal_distance = 3000, min_percent = 1, stochastic_resampling = FALSE, progress = TRUE )
dispersal( sf, SpParams, local_control = medfate::defaultControl(), distance_step = 25, maximum_dispersal_distance = 3000, min_percent = 1, stochastic_resampling = FALSE, progress = TRUE )
sf |
An object of class
|
SpParams |
A data frame with species parameters (see |
local_control |
A list of control parameters (see |
distance_step |
Distance step in meters. |
maximum_dispersal_distance |
Maximum dispersal distance in meters. |
min_percent |
A minimum percent of seed bank to retain entry in |
stochastic_resampling |
A flag to indicate that stochastic resampling of stands is performed. |
progress |
Boolean flag to display progress information. |
The input 'sf' object has to be in a Universal Transverse Mercator (UTM) coordinate system (or any other projection using meters as length unit) for appropriate function behavior.
Dispersal kernel follows Clark et al. (1999) and potential seed donors (neighbors) are defined up to a given grid distance order. A maximum value of 100% seed bank refill is attained for species with seed production in all seed donors and the local cell.
A list with forest objects (for wildland cover type) containing a modified seed bank
Miquel De Cáceres Ainsa, CREAF.
Roberto Molowny-Horas, CREAF.
Clark et al. (1999). Seed dispersal near and far: Patterns across temperate and tropical forests. Ecology 80(5):1475-1494
data(example_watershed) data(SpParamsMED) # Transform to UTM31 example_watershed_utm31 <- sf::st_transform(example_watershed, crs = 32631) # Estimate seed production and dispersal over the watershed seedbank_list <- dispersal(example_watershed_utm31, SpParamsMED) seedbank_list[[1]] # Transform to UTM31 example_ifn_utm31 <- sf::st_transform(example_ifn, crs = 32631) # Estimate seed production and dispersal over the set of forest inventory plots seedbank_list <- dispersal(example_ifn_utm31, SpParamsMED) seedbank_list[[1]]
data(example_watershed) data(SpParamsMED) # Transform to UTM31 example_watershed_utm31 <- sf::st_transform(example_watershed, crs = 32631) # Estimate seed production and dispersal over the watershed seedbank_list <- dispersal(example_watershed_utm31, SpParamsMED) seedbank_list[[1]] # Transform to UTM31 example_ifn_utm31 <- sf::st_transform(example_ifn, crs = 32631) # Estimate seed production and dispersal over the set of forest inventory plots seedbank_list <- dispersal(example_ifn_utm31, SpParamsMED) seedbank_list[[1]]
An example of an coordinates, topography, forest and soil data corresponding to 30 forest inventory plots.
The data format is that of an object sf
Soil data from SoilGrids global database (Hengl et al. 2017).
Soil depth and depth to bedrock from Shangguan et al. (2017).
Forest structure and composition from the Third Spanish Forest Inventory (IFN3).
An example of an object of sf
with data for a small catchment of 66 ha (0.66 km2) in Catalonia.
Object example_watershed_burnin
is the result of three years of burn-in period.
The data format is that of an object sf
Watershed limits and channel network from the spanish Ministerio de Transición Ecológica y el Reto Demográfico.
Elevation data at 30 m resolution from catalan Institut Cartogràfic i Geològic de Catalunya.
Soil data from SoilGrids global database (Hengl et al. 2017).
Soil depth and depth to bedrock from Shangguan et al. (2017).
Bedrock hydraulic properties from Huscroft et al. (2018).
Land cover data from Mapa Forestal de España 1:25000.
Forest structure and composition from Mapa Forestal de España 1:25000 and the Third Spanish Forest Inventory (IFN3).
Hengl, T., Mendes De Jesus, J., Heuvelink, G.B.M., Gonzalez, M.R., Kilibarda, M., Blagotí, A., Shangguan, W., Wright, M.N., Geng, X., Bauer-Marschallinger, B., Guevara, M.A., Vargas, R., Macmillan, R.A., Batjes, N.H., Leenaars, J.G.B., Ribeiro, E., Wheeler, I., Mantel, S., Kempen, B., 2017. SoilGrids250m: Global Gridded Soil Information Based on Machine Learning. PLoS One 12, e0169748. doi:10.1371/journal.pone.0169748
Huscroft, J., Gleeson, T., Hartmann, J., Börker, J., 2018. Compiling and Mapping Global Permeability of the Unconsolidated and Consolidated Earth: GLobal HYdrogeology MaPS 2.0 (GLHYMPS 2.0). Geophys. Res. Lett. 45, 1897–1904. doi:10.1002/2017GL075860
Shangguan, W., Hengl, T., Mendes de Jesus, J., Yuan, H., Dai, Y., 2017. Mapping the global depth to bedrock for land surface modeling. J. Adv. Model. Earth Syst. 9, 65–88. doi:10.1002/2016MS000686
Extract or estimate variables from landscape objects (class 'sf').
extract_variables(x, vars = "land_cover_type", SpParams = NULL, ...) plot_variable(x, variable = "land_cover_type", SpParams = NULL, r = NULL, ...)
extract_variables(x, vars = "land_cover_type", SpParams = NULL, ...) plot_variable(x, variable = "land_cover_type", SpParams = NULL, r = NULL, ...)
x |
An object of class |
vars |
A string vector with the name of the variables to extract (see details). |
SpParams |
A data frame with species parameters (see |
... |
Additional arguments (not used). |
variable |
A string with the name of the variables to draw (see details). |
r |
An object of class |
The following string values are available for vars
.
Topography:
"elevation"
: Elevation in m.
"slope"
: Slope in degrees.
"aspect"
: Slope in degrees.
"land_cover_type"
: Land cover type.
Soil:
"soil_vol_extract"
: Total water extractable volume (mm).
"soil_vol_sat"
: Total water volume at saturation (mm).
"soil_vol_fc"
: Total water volume at field capacity (mm).
"soil_vol_wp"
: Total water volume at wilting point (mm).
"soil_vol_curr"
: Current total water volume (mm).
"soil_rwc_curr"
: Current soil relative water content (%).
"soil_rew_curr"
: Current soil relative extractable water (%).
"soil_theta_curr"
: Current soil moisture content (% vol.)
"soil_psi_curr"
: Current soil water potential (MPa).
Watershed:
"depth_to_bedrock"
: Depth to bedrock (m).
"bedrock_porosity"
: Bedrock porosity.
"bedrock_conductivity"
: Bedrock conductivity (m/day).
"aquifer_elevation"
: Aquifer elevation over bedrock (m).
"depth_to_aquifer"
: Depth to aquifer (m).
"aquifer"
: Aquifer volume (mm).
"snowpack"
: Snowpack water equivalent (mm).
Forest stand:
"basal_area"
: Basal area (m2/ha).
"tree_density"
: Tree density (ind/ha).
"mean_tree_height"
: Mean tree height (cm).
"dominant_tree_height"
: Dominant tree height (cm).
"dominant_tree_diameter"
: Dominant tree diameter (cm).
"quadratic_mean_tree_diameter"
: Quadratic mean tree diameter (cm).
"hart_becking_index"
: Hart-Becking index.
"leaf_area_index"
: Leaf area index (m2/m2).
"foliar_biomass"
: Foliar biomass (kg/m2).
"fuel_loading"
: Fine live fuel loading (kg/m2).
"shrub_volume"
: Shrub volume (m3/m2).
Function extract_variables()
returns an object of class sf
with the desired variables.
Function plot_variables()
returns a ggplot object.
Miquel De Cáceres Ainsa, CREAF.
forest
, soil
, summary.forest
, shinyplot_land
# Load data and species parameters from medfate data(example_ifn) data(SpParamsMED) # Calculate basal area and leaf area index # for all forest stands extract_variables(example_ifn, vars = c("basal_area", "leaf_area_index"), SpParams = SpParamsMED)
# Load data and species parameters from medfate data(example_ifn) data(SpParamsMED) # Calculate basal area and leaf area index # for all forest stands extract_variables(example_ifn, vars = c("basal_area", "leaf_area_index"), SpParams = SpParamsMED)
Applies a fire regime object over a set of landscape units to determine a fire realization
fire_regime_instance(sf, fire_regime)
fire_regime_instance(sf, fire_regime)
sf |
An object of class
|
fire_regime |
A list of parameters defining the fire regime (see |
The function randomly determines the landscape units that will burn every year, depending on the specifications
of the fire regime object. Users can define their own fire regime instances from other models (e.g. a fire landscape model)
and then use those directly in functions fordyn_spatial
or fordyn_scenario
.
An integer matrix specifying the day of the year of burning of each landscape unit for every year in the fire regime definition. Values are interpreted as follows:
NA - No wildfire this year
0 - Wildfire will occur the driest day (i.e. the one with largest vapor pressure deficit).
1...366 - Day of the year when wildfire will occur
Miquel De Cáceres Ainsa, CREAF
create_fire_regime
, fordyn_spatial
, fordyn_scenario
# Load example data data("example_ifn") # Assume that each stand represents 1km2 = 100 ha example_ifn$represented_area_ha <- 100 # Define fire regime characteristics reg1 <- create_fire_regime(c("2002" = 200, "2003" = 500)) # Create a fire regime instance m1 <- fire_regime_instance(example_ifn, reg1) # Check number of plots burned colSums(!is.na(m1)) # Define fire regime characteristics with stochastic area burned reg2 <- create_fire_regime(annual_burned_area = c("2002" = 200, "2003" = 500), sd_burned_area = c("2002" = 0.4, "2003" = 0.5)) # Create a fire regime instance m2 <- fire_regime_instance(example_ifn, reg2) # Check number of plots burned colSums(!is.na(m2))
# Load example data data("example_ifn") # Assume that each stand represents 1km2 = 100 ha example_ifn$represented_area_ha <- 100 # Define fire regime characteristics reg1 <- create_fire_regime(c("2002" = 200, "2003" = 500)) # Create a fire regime instance m1 <- fire_regime_instance(example_ifn, reg1) # Check number of plots burned colSums(!is.na(m1)) # Define fire regime characteristics with stochastic area burned reg2 <- create_fire_regime(annual_burned_area = c("2002" = 200, "2003" = 500), sd_burned_area = c("2002" = 0.4, "2003" = 0.5)) # Create a fire regime instance m2 <- fire_regime_instance(example_ifn, reg2) # Check number of plots burned colSums(!is.na(m2))
Evaluates forest dynamics over a landscape including climate and management scenarios
fordyn_scenario( sf, SpParams, meteo = NULL, management_scenario, volume_function = NULL, volume_arguments = NULL, local_control = defaultControl(), dispersal_control = default_dispersal_control(), dates = NULL, CO2ByYear = numeric(0), fire_regime = NULL, summary_function = NULL, summary_arguments = NULL, parallelize = FALSE, num_cores = detectCores() - 1, chunk_size = NULL, progress = TRUE, verbose = FALSE )
fordyn_scenario( sf, SpParams, meteo = NULL, management_scenario, volume_function = NULL, volume_arguments = NULL, local_control = defaultControl(), dispersal_control = default_dispersal_control(), dates = NULL, CO2ByYear = numeric(0), fire_regime = NULL, summary_function = NULL, summary_arguments = NULL, parallelize = FALSE, num_cores = detectCores() - 1, chunk_size = NULL, progress = TRUE, verbose = FALSE )
sf |
An object of class
Alternatively, the user may supply the result of a previous call to |
SpParams |
A data frame with species parameters (see |
meteo |
Meteorology data (see |
management_scenario |
A list defining the management scenario (see |
volume_function |
A function accepting a forest object or a tree data table, and a species parameter table, as input and returning the wood volume (m3/ha) corresponding to each tree cohort. The function may accept additional arguments. If NULL, the default volume function is used (not recommended!). |
volume_arguments |
List with additional arguments for the volume function. |
local_control |
A list of local model control parameters (see |
dispersal_control |
A list of dispersal control parameters (see |
dates |
A |
CO2ByYear |
A named numeric vector with years as names and atmospheric CO2 concentration (in ppm) as values. Used to specify annual changes in CO2 concentration along the simulation (as an alternative to specifying daily values in |
fire_regime |
A list of parameters defining the fire regime (see |
summary_function |
An appropriate function to calculate summaries from an object of class 'fordyn' (e.g., |
summary_arguments |
List with additional arguments for the summary function. |
parallelize |
Boolean flag to try parallelization (will use all clusters minus one). |
num_cores |
Integer with the number of cores to be used for parallel computation. |
chunk_size |
Integer indicating the size of chunks to be sent to different processes (by default, the number of spatial elements divided by the number of cores). |
progress |
Boolean flag to display progress information for simulations. |
verbose |
Boolean flag to display additional console output. |
This function allows coordinating the dynamics of simulated forest stands via a management scenario
defined at the landscape/regional level (see different kinds of scenarios and how to specify them in create_management_scenario
).
The input 'sf' object has to be in a Universal Transverse Mercator (UTM) coordinate system (or any other projection using meters as length unit) for appropriate behavior of dispersal sub-model.
For each year to be simulated, the function determines which forest stands will be managed, possibly depending on the demand,
and then calls function fordyn_spatial
for one year (normally including parallelization).
If the simulation of some stands results in an error, the function will try to restore
the previous state of the forest stand for the next year steps. Finally, the function evaluates how much of the specified demand
has been fulfilled and stores the results, including demand offsets to be applied the year after.
Management is implemented using the defaultManagementFunction
in medfate,
meaning that management parameters need to follow the structure of defaultManagementArguments
Details about the inclusion of fire regimes in simulations are explained in fordyn_spatial
.
An list of class 'fordyn_scenario' with the following elements:
result_sf
: An object of class 'sf' using a UTM projection and containing four elements:
geometry
: Spatial geometry.
id
: Stand id, taken from the input.
tree_table
: A list of data frames for each simulated stand, containing the living trees at each time step.
shrub_table
: A list of data frames for each simulated stand, containing the living shrub at each time step.
dead_tree_table
: A list of data frames for each simulated stand, containing the dead trees at each time step.
dead_shrub_table
: A list of data frames for each simulated stand, containing the dead shrub at each time step.
cut_tree_table
: A list of data frames for each simulated stand, containing the cut trees at each time step.
cut_shrub_table
: A list of data frames for each simulated stand, containing the cut shrub at each time step.
summary
: A list of model output summaries for each simulated stand (if summary_function
was not NULL
).
result_volumes
: A data frame with initial, growth, extracted and final volumes (m3) by year. In demand-based scenarios volumes corresponding to species with demand are also included.
result_volumes_spp
: A data frame with growth and extracted volumes (m3) by species and year.
result_volumes_demand
: In demand-based scenarios target volumes are also included, a data frame with growth, target and extracted volumes (m3) by demand entity and year. .
next_sf
: An object of class 'sf' to continue simulations in subsequent calls to fordyn_scenario
.
next_demand
: In demand-based scenarios, a list with information (i.e. demand offset by species and last volume growth)
to modify demand in subsequent calls to fordyn_scenario
.
Miquel De Cáceres Ainsa, CREAF
Aitor Améztegui, UdL
fordyn_spatial
, create_management_scenario
, dispersal
# Load example landscape data data("example_ifn") # Load example meteo data frame from package meteoland data("examplemeteo") # Load default medfate parameters data("SpParamsMED") # Creates scenario with one management unit and annual demand for P. nigra scen <- create_management_scenario(1, c("Pinus nigra/Pinus sylvestris" = 2300)) # Assign management unit to all stands example_ifn$management_unit <- 1 # Assume that each stand represents 1km2 = 100 ha example_ifn$represented_area_ha <- 100 # Transform to UTM31 (necessary for dispersal) example_ifn_utm31 <- sf::st_transform(example_ifn, crs = 32631) # Subset three plots to speed-up calculations example_subset <- example_ifn_utm31[31:33, ] # Launch simulation scenario fs_12 <- fordyn_scenario(example_subset, SpParamsMED, meteo = examplemeteo, volume_function = NULL, management_scenario = scen, parallelize = FALSE)
# Load example landscape data data("example_ifn") # Load example meteo data frame from package meteoland data("examplemeteo") # Load default medfate parameters data("SpParamsMED") # Creates scenario with one management unit and annual demand for P. nigra scen <- create_management_scenario(1, c("Pinus nigra/Pinus sylvestris" = 2300)) # Assign management unit to all stands example_ifn$management_unit <- 1 # Assume that each stand represents 1km2 = 100 ha example_ifn$represented_area_ha <- 100 # Transform to UTM31 (necessary for dispersal) example_ifn_utm31 <- sf::st_transform(example_ifn, crs = 32631) # Subset three plots to speed-up calculations example_subset <- example_ifn_utm31[31:33, ] # Launch simulation scenario fs_12 <- fordyn_scenario(example_subset, SpParamsMED, meteo = examplemeteo, volume_function = NULL, management_scenario = scen, parallelize = FALSE)
Utility functions to define forest inputs in a landscape:
impute_forests()
performs imputation of forest objects from a forest inventory using a forest map to match forest types and topography as covariates.
modify_forest_structure()
uses forest structure rasters supplied by the user to correct forest structure metrics.
check_forests()
checks that forests are defined and do not contain missing values in key tree/shrub attributes.
impute_forests( x, sf_fi, dem, forest_map, var_class = NA, max_distance_km = 100, replace_existing = FALSE, missing_class_imputation = FALSE, missing_class_forest = NULL, merge_trees = TRUE, merge_shrubs = TRUE, progress = TRUE ) modify_forest_structure( x, structure_map, variable, map_var = NA, ratio_limits = NULL, minDBH = 7.5, progress = TRUE )
impute_forests( x, sf_fi, dem, forest_map, var_class = NA, max_distance_km = 100, replace_existing = FALSE, missing_class_imputation = FALSE, missing_class_forest = NULL, merge_trees = TRUE, merge_shrubs = TRUE, progress = TRUE ) modify_forest_structure( x, structure_map, variable, map_var = NA, ratio_limits = NULL, minDBH = 7.5, progress = TRUE )
x |
An object of class |
sf_fi |
An object of class |
dem |
A digital elevation model (class |
forest_map |
An object of class |
var_class |
Variable name or index containing forest classes in |
max_distance_km |
Maximum distance, in km, for forest inventory plot imputation. |
replace_existing |
A logical flag to force the replacement of existing |
missing_class_imputation |
A logical flag to force imputation in locations where forest class is not defined. If |
missing_class_forest |
A |
merge_trees |
A logical flag to simplify tree cohorts by merging tree records in DBH classes (see |
merge_shrubs |
A logical flag to simplify shrub cohorts by merging shrub records in height classes (see |
progress |
A logical flag to print console output. |
structure_map |
An object of class |
variable |
Structural variable to correct. See options in details. |
map_var |
Variable name or index containing structural variable in 'structure_map'. If missing the first column is taken. |
ratio_limits |
Limits for ratio of variable in corrections, used to avoid outliers. |
minDBH |
Minimum diameter for stand metric calculation. If |
Function impute_forests()
performs imputation of forest inventory plots on target locations provided that
they correspond to the same forest class, defined in the input forest map, and are geographically closer than a distance threshold (max_distance_km
).
Among the multiple stands that can have fulfill these two requirements, the function chooses the one that has the most similar elevation
and position in the N-to-S slopes (i.e. the product of the cosine of aspect and slope). Both topographic
features are standardized to zero mean and unit standard deviation (using the supplied digital elevation model to calculate those metrics), to make their
weight on the imputation equal. This imputation method will be more or less successful depending on the resolution of forest classes and
the number of forest inventory plots available for each of them. Additionally, tree and shrub cohorts can be simplified after imputation (merge_trees
and merge_shrubs
),
to reduce the number of records (and hence, speed-up simulations).
Function modify_forest_structure()
can be used to modify specific structure variables of the imputed forests
building on rasters supplied by the user (typically from aerial or satellite LiDAR products). For any given metric,
the function will calculate the ratio of the structure metric between the target forest
object (see stand_basalArea
)
and the input map in the target location. Options for structural variables are the following:
mean_tree_height
: Should contain values in cm. Corrects tree heights and diameters (assuming a constant diameter-height relationship).
dominant_tree_height
: Should contain values in cm. Corrects tree heights and diameters (assuming a constant diameter-height relationship).
tree_density
: Should contain values in individuals per hectare. Corrects tree density.
basal_area
: Should contain values in squared meters per hectare (m2/ha). Corrects tree density. Forests that
mean_shrub_height
: Should contain values in cm. Corrects shrub cover.
Locations where the metric value in the map is missing are left unmodified. The same happens if metric value is zero, to avoid division by zero. A special case occurs
for correction of basal area. In that case, if there are no trees larger than minDBH
but structural map indicates positive values of basal area,
DBH values will be set to minDBH, and correction of basal area will be performed.
Functions impute_forests()
and modify_forest_structure()
return a modified object of class sf
.
Function check_forests()
returns an invisible data frame with columns indicating missing forest data and missing values in tree or shrub parameters.
Miquel De Cáceres Ainsa, CREAF
Rodrigo Balaguer-Romano, CREAF
add_topography()
, add_forests()
, add_soilgrids()
, forest_mergeTrees
# See package vignettes 'Preparing inputs'
# See package vignettes 'Preparing inputs'
Initializes state for local models spwb
or growth
.
initialize_landscape( x, SpParams, local_control, model = "spwb", simplify = FALSE, replace = FALSE, progress = TRUE )
initialize_landscape( x, SpParams, local_control, model = "spwb", simplify = FALSE, replace = FALSE, progress = TRUE )
x |
An object of class
|
SpParams |
A data frame with species parameters (see |
local_control |
A list of control parameters (see |
model |
A string to indicate the model, either |
simplify |
Boolean flag to simplify forest to the tree and shrub cohorts with largest leaf area index. The leaf area index of the whole tree (respectively, shrub) layer will be attributed to the selected cohort.
See function |
replace |
Boolean flag to replace existing initialized states |
progress |
Boolean flag to display progress information. |
Initialization is dealt automatically when calling simulation functions spwb_spatial
, growth_spatial
,
spwb_spatial_day
or growth_spatial_day
. However, function initialize_landscape
allows separating initialization from model simulations.
Option simplify
has been implemented to allow simplification of forests to tree/shrub dominant cohorts during watershed simulations
where focus is on runoff (e.g. calibration of watershed parameters or burnin periods). Elements identified as result_cell
will not be simplified.
Replaces or adds column 'state' whose elements are spwbInput
or growthInput
objects
and returns the modified object of class 'sf'.
Miquel De Cáceres Ainsa, CREAF
spwb_spatial
, spwb_spatial_day
,
update_landscape
# Load example landscape data data("example_ifn") # Load example meteo data frame from package meteoland data("examplemeteo") # Load default medfate parameters data("SpParamsMED") # Define local control parameters using function in medfate local_control <- defaultControl() # If necessary, change defaults # Initialize state for 'spwb' simulations example_ifn_init <- initialize_landscape(example_ifn, SpParamsMED, local_control = local_control, model = "spwb")
# Load example landscape data data("example_ifn") # Load example meteo data frame from package meteoland data("examplemeteo") # Load default medfate parameters data("SpParamsMED") # Define local control parameters using function in medfate local_control <- defaultControl() # If necessary, change defaults # Initialize state for 'spwb' simulations example_ifn_init <- initialize_landscape(example_ifn, SpParamsMED, local_control = local_control, model = "spwb")
Functions to calculates a summary function for the forest or soil of all spatial elements
in an object of class sf
containing landscape information.
landscape_summary( object, name, summary_function, ..., unlist = FALSE, progress = FALSE )
landscape_summary( object, name, summary_function, ..., unlist = FALSE, progress = FALSE )
object |
An object of class |
name |
A string of the element to summarize: "forest", "soil" or "state". |
summary_function |
A function that accepts objects of class |
... |
Additional arguments to the summary function. |
unlist |
Logical flag to try converting the summaries into different columns |
progress |
Boolean flag to display progress information |
An object of class sf
containing the calculated statistics.
If unlist = FALSE
column 'summary' is a list with summaries for each element.
If unlist = TRUE
different columns are returned instead, one per variable given in the summary function.
Miquel De Cáceres Ainsa, CREAF.
# Load plot data and species parameters from medfate data(example_ifn) # Load default medfate parameters data("SpParamsMED") # Apply forest summary function landscape_summary(example_ifn, "forest", summary.forest, SpParamsMED)
# Load plot data and species parameters from medfate data(example_ifn) # Load default medfate parameters data("SpParamsMED") # Apply forest summary function landscape_summary(example_ifn, "forest", summary.forest, SpParamsMED)
Transforms a data frame or sf object issued from package forestables into an sf object for simulations with medfateland.
parse_forestable( x, keepSpeciesCodes = TRUE, filterMissingSpecies = TRUE, filterDeadTrees = TRUE, filterCutTrees = TRUE, keepUnfilteredCopy = FALSE, minimumTreeDBH = 0.1, progress = FALSE )
parse_forestable( x, keepSpeciesCodes = TRUE, filterMissingSpecies = TRUE, filterDeadTrees = TRUE, filterCutTrees = TRUE, keepUnfilteredCopy = FALSE, minimumTreeDBH = 0.1, progress = FALSE )
x |
A data frame or sf object issued from package forestables. |
keepSpeciesCodes |
Keeps forest inventory species codes. |
filterMissingSpecies |
If TRUE, filters out records where species is missing. |
filterDeadTrees |
If TRUE, filters out dead trees (Spanish forest inventory IFN3 or IFN4). |
filterCutTrees |
If TRUE, filters out cut trees (Spanish forest inventory IFN3 or IFN4). |
keepUnfilteredCopy |
If TRUE, an additional column is given where dead/cut trees have not been filtered. |
minimumTreeDBH |
Minimum DBH for keeping a tree record. |
progress |
A logical flag to include a progress bar while processing the data. |
This function retrieves the following information from the forestables object:
Id unique code, survey year, non-unique plot code and country.
Plot location. Output geometry is always points in WGS 84. Note that exact coordinates are not normally given in forest inventory data.
Elevation, slope and aspect, whenever available
Tree and understory data. The function will create a column forest
with this information. If both tree and understory data are
missing for a given row, the corresponding forest
will be empty.
An sf object including a 'forest' column. If keepUnfilteredCopy=TRUE
an additional column 'forest_unfiltered' is also given.
Produces graphical output of the summaries of a simulation models
plot_summary(x, variable, date, r = NULL, ...)
plot_summary(x, variable, date, r = NULL, ...)
x |
An object of class |
variable |
The variable to be drawn. |
date |
The date of the summary to be plotted. |
r |
An object of class |
... |
Additional parameters (passed to scale definition, such as |
Appropriate values for x
can originate from calls to simulation_summary
.
Alternatively, if summary functions were specified at the time of performing simulations,
the result of the spatial simulation function (e.g. spwb_spatial
)
will already contain the summaries. A special case is made for spwb_land
and growth_land
,
that are accepted inputs as x
, because its element 'sf' is used.
An object of class ggplot
.
Miquel De Cáceres Ainsa, CREAF.
spwb_spatial
, simulation_summary
Creates a shiny app with interactive plots for spatial inputs and simulation results
shinyplot_land(x, SpParams = NULL, r = NULL)
shinyplot_land(x, SpParams = NULL, r = NULL)
x |
The object of class 'sf' containing information to be drawn (see details). Alternatively, an object of class 'spwb_land', 'growth_land' or 'fordyn_land'. |
SpParams |
A data frame with species parameters (see |
r |
An object of class |
Only run this function in interactive mode. The shiny app can be used to display spatial inputs or simulation results.
Spatial inputs:
This is the case if the user supplies an object of class sf
with simulation inputs.
Simulation result summaries:
This is the case if the user supplies an object of class sf
with simulation summaries. Available plots depend on the summary function used to create the result summaries.
An object that represents the shiny app
Miquel De Cáceres Ainsa, CREAF
plot_summary
, extract_variables
Creates spatial objects containing summaries of simulations
simulation_summary(object, summary_function, ...)
simulation_summary(object, summary_function, ...)
object |
An object of class 'sf' simulation results (e.g. the result of calling |
summary_function |
The summary function to be executed on simulation results (see details). |
... |
Additional parameters to the summary function. |
The function supplied should take as input an object of local simulation function, i.e. spwb
, growth
, or fordyn
.
The output should be a matrix with dates as rows and variables in columns.
An example of suitable function is summary.spwb
.
An object of class sf
, with the following two elements:
geometry
: Spatial geometry.
id
: Stand id, taken from the input.
summary
: A list of model output summaries for each simulated location.
Miquel De Cáceres Ainsa, CREAF.
Function add_soilgrids
fills column 'soil' with physical soil characteristics drawn from SoilGrids 2.0 (Hengl et al. 2017; Poggio et al. 2021).
Function modify_soils
modifies soil definition according to soil depth and depth to bedrock information.
Function check_soils
verifies that soil data does not contain missing values for key variables and, if so, assigns default values.
add_soilgrids( x, soilgrids_path = NULL, widths = NULL, replace_existing = TRUE, progress = TRUE ) modify_soils( x, soil_depth_map = NULL, depth_to_bedrock_map = NULL, regolith_rfc = 97.5, full_rock_filling = TRUE, progress = TRUE )
add_soilgrids( x, soilgrids_path = NULL, widths = NULL, replace_existing = TRUE, progress = TRUE ) modify_soils( x, soil_depth_map = NULL, depth_to_bedrock_map = NULL, regolith_rfc = 97.5, full_rock_filling = TRUE, progress = TRUE )
x |
An object of class |
soilgrids_path |
Path to SoilGrids rasters (see details). If missing, the SoilGrids REST API (https://rest.isric.org) will be queried. |
widths |
A numeric vector indicating the desired layer widths, in mm. If |
replace_existing |
A logical flag to force the replacement of existing soil data, when already present |
progress |
A logical flag to include a progress bar while processing the output of the query to the SoilGrids REST API. |
soil_depth_map |
An object of class |
depth_to_bedrock_map |
An object of class |
regolith_rfc |
Rock fragment content, in percent volume, between soil depth and 200cm depth (or lower depths, if modified via |
full_rock_filling |
Logical flag to modify rock fragment content in all soil layers with according to distance to soil depth. |
If soilgrids_path = NULL
the function connects with the SoilGrids REST API (https://rest.isric.org)
to retrieve the soil physical and chemical characteristics for a site (Hengl et al. 2007; Poggio et al. 2021), selected
by its coordinates. Also, in case the depths are not the default ones in the SoilGrids API, the function uses
averages the values of soil grid layers depending on the overlap between soil layer definitions. Unfortunately,
SoilGrids REST API queries are limited to a few points.
If soilgrids_path != NULL
the function will read SoilGrid rasters from the file disk. Folders need to be defined
for each variable ("sand", "clay", "soc", "bdod", "cfvo" and "nitrogen"). File paths from soilgrids_path
should be named:
var/var_layer_mean.tif
where var is one of the above and layer is "0-5cm", "5-15cm", "15-30cm", "30-60cm", "60-100cm" or "100-200cm"
SoilGrids does not provide soil depth estimates. Function modify_soils
is designed to adjust soil depths according to available information.
When soil_depth_map
is provided, the function adjusts rock fragment content of layers below soil depth with the value of regolith_rfc
.
When depth_to_bedrock_map
is provided, the function truncates the total depth of the soil definition to the depth to bedrock.
If regional maps of soil depth are not available, users are recommended to resort on Shangguan et al (2017).
A modified object of class sf
with column 'soil'.
Víctor Granda, EMF-CREAF
Miquel De Cáceres Ainsa, EMF-CREAF
Hengl T, Mendes de Jesus J, Heuvelink GBM, Ruiperez Gonzalez M, Kilibarda M, Blagotić A, et al. (2017) SoilGrids250m: Global gridded soil information based on machine learning. PLoS ONE 12(2): e0169748. doi:10.1371/journal.pone.0169748.
Poggio L, de Sousa LM, Batjes NH, Heuvelink GBM, Kempen B, Ribeiro E, Rossiter D (2021). SoilGrids 2.0: producing soil information for the globe with quantified spatial uncertainty. SOIL 7, 217-240. doi: 10.5194/soil-7-217-2021
Shangguan W, Hengl T, Mendes de Jesus J, Yuan H, Dai J (2017). Mapping the global depth to bedrock for land surface modeling. Journal of Advances in Modeling Earth Systems 9: 65-88. doi: 10.1002/2016MS000686
add_topography()
, impute_forests()
, soil
, defaultSoilParams
library(sf) x <- st_sf(geometry = st_sfc(st_point(c(-5.6333, 42.6667)), crs = 4326)) x_soil <- add_soilgrids(x, widths = c(300, 700, 1000)) x_soil # See more complete examples in package vignettes 'Preparing inputs'
library(sf) x <- st_sf(geometry = st_sfc(st_point(c(-5.6333, 42.6667)), crs = 4326)) x_soil <- add_soilgrids(x, widths = c(300, 700, 1000)) x_soil # See more complete examples in package vignettes 'Preparing inputs'
Functions to perform simulations on a watershed described by a set of connected grid cells.
Function spwb_land
implements a distributed hydrological model that simulates daily local water balance, from spwb_day
,
on grid cells of a watershed while accounting for overland runoff, subsurface flow and groundwater flow between cells.
Function growth_land
is similar to spwb_land
, but includes daily local carbon balance, growth and mortality processes in grid cells,
provided by growth_day
.
Function fordyn_land
extends the previous two functions with the simulation of management, seed dispersal, recruitment
and resprouting.
spwb_land( r, sf, SpParams, meteo = NULL, dates = NULL, CO2ByYear = numeric(0), summary_frequency = "years", local_control = defaultControl(soilDomains = "single"), watershed_control = default_watershed_control(), parallelize = FALSE, num_cores = detectCores() - 1, chunk_size = NULL, progress = TRUE ) growth_land( r, sf, SpParams, meteo = NULL, dates = NULL, CO2ByYear = numeric(0), summary_frequency = "years", local_control = medfate::defaultControl(soilDomains = "single"), watershed_control = default_watershed_control(), parallelize = FALSE, num_cores = detectCores() - 1, chunk_size = NULL, progress = TRUE ) fordyn_land( r, sf, SpParams, meteo = NULL, dates = NULL, CO2ByYear = numeric(0), local_control = medfate::defaultControl(soilDomains = "single"), watershed_control = default_watershed_control(), dispersal_control = default_dispersal_control(), management_function = NULL, parallelize = FALSE, num_cores = parallel::detectCores() - 1, chunk_size = NULL, progress = TRUE ) cell_neighbors(sf, r) ## S3 method for class 'spwb_land' summary(object, ...) ## S3 method for class 'growth_land' summary(object, ...)
spwb_land( r, sf, SpParams, meteo = NULL, dates = NULL, CO2ByYear = numeric(0), summary_frequency = "years", local_control = defaultControl(soilDomains = "single"), watershed_control = default_watershed_control(), parallelize = FALSE, num_cores = detectCores() - 1, chunk_size = NULL, progress = TRUE ) growth_land( r, sf, SpParams, meteo = NULL, dates = NULL, CO2ByYear = numeric(0), summary_frequency = "years", local_control = medfate::defaultControl(soilDomains = "single"), watershed_control = default_watershed_control(), parallelize = FALSE, num_cores = detectCores() - 1, chunk_size = NULL, progress = TRUE ) fordyn_land( r, sf, SpParams, meteo = NULL, dates = NULL, CO2ByYear = numeric(0), local_control = medfate::defaultControl(soilDomains = "single"), watershed_control = default_watershed_control(), dispersal_control = default_dispersal_control(), management_function = NULL, parallelize = FALSE, num_cores = parallel::detectCores() - 1, chunk_size = NULL, progress = TRUE ) cell_neighbors(sf, r) ## S3 method for class 'spwb_land' summary(object, ...) ## S3 method for class 'growth_land' summary(object, ...)
r |
An object of class |
sf |
An object of class
When using TETIS watershed model, the following columns are also REQUIRED:
When using TETIS watershed model, the following columns are OPTIONAL:
|
SpParams |
A data frame with species parameters (see |
meteo |
Input meteorological data (see |
dates |
A |
CO2ByYear |
A named numeric vector with years as names and atmospheric CO2 concentration (in ppm) as values. Used to specify annual changes in CO2 concentration along the simulation (as an alternative to specifying daily values in |
summary_frequency |
Frequency in which cell summary will be produced (e.g. "years", "months", ...) (see |
local_control |
A list of control parameters (see |
watershed_control |
A list of watershed control parameters (see |
parallelize |
Boolean flag to try parallelization (see details). |
num_cores |
Integer with the number of cores to be used for parallel computation (by default it will use all clusters minus one). |
chunk_size |
Integer indicating the size of chunks to be sent to different processes (by default, the number of spatial elements divided by the number of cores). |
progress |
Boolean flag to display progress information for simulations. |
dispersal_control |
A list of dispersal control parameters (see |
management_function |
A function that implements forest management actions (see |
object |
An object of class |
... |
Additional parameters for summary functions |
The default soilDomains = "single"
means that vertical bulk soil flows are simulated using a single permeability domain with Richards equation.
Two sub-models are available for lateral water transfer processes (overland flow, sub-surface flow, etc.), either "TETIS" (similar to Francés et al. 2007) or "SERGHEI" (Caviedes-Voullième et al. 2023).
IMPORTANT: medfateland needs to be compiled along with SERGHEI model in order to launch simulations with using this distributed hydrological model.
When running fordyn_land
, the input 'sf' object has to be in a Universal Transverse Mercator (UTM) coordinate system (or any other projection using meters as length unit)
for appropriate behavior of dispersal sub-model.
Parallel computation is only recommended for watersheds with large number of grid cells (e.g. > 10,000 when using transpirationMode = "granier"
).
In watershed with a small number of cells, parallel computation can result in larger processing times than sequential computation, due
to the communication overload.
When dealing with large data sets, weather data included in the 'sf' object will likely be very data hungry. In those cases, it is
recommended to resort on weather interpolation (see spwb_spatial
). Weather interpolation can be done using a coarser resolution
than that of raster 'r', by changing the watershed control parameter called 'weather_aggregation_factor' (see default_watershed_control
).
Functions spwb_land
, growth_land
and fordyn_land
return a list of class of the same name as the function with the following elements:
watershed_control
: A list with input control parameters.
sf
: An object of class sf
, similar to the output of spwb_spatial
,
with the following columns:
geometry
: Spatial geometry.
state
: A list of model input objects for each simulated stand.
aquifer
: A numeric vector with the water volume in the aquifer of each cell.
snowpack
: A numeric vector with the snowpack water equivalent volume of each cell.
summary
: A list of cell summaries, containing the following variables:
MinTemperature
: Minimum temperature (degrees Celsius).
MaxTemperature
: Maximum temperature (degrees Celsius).
PET
: Potential evapotranspiration (in mm).
Rain
: Rainfall (in mm).
Snow
: Snowfall (in mm).
Snowmelt
: Snow melt (in mm).
Interception
: Rainfall interception (in mm).
NetRain
: Net rainfall, i.e. throughfall, (in mm).
Infiltration
: The amount of water infiltrating into the soil (in mm).
InfiltrationExcess
: The amount of water exceeding the soil infiltration capacity (in mm).
SaturationExcess
: The amount of water that reaches the soil surface because of soil saturation (in mm).
Runon
: The amount of water reaching the cell via surface runon (in mm).
Runoff
: The amount of water exported from the cell via surface runoff (in mm).
DeepDrainage
: The amount of water draining from soil to the aquifer via deep drainage (in mm).
CapillarityRise
: Water entering the soil via capillarity rise (mm) from the water table.
SoilEvaporation
: Bare soil evaporation (in mm).
Transpiration
: Woody plant transpiration (in mm).
HerbTranspiration
: Herbaceous transpiration (in mm).
InterflowInput
: The amount of water that reaches the soil of the cell from adjacent cells via subsurface flow (in mm).
InterflowOutput
: The amount of water that leaves the soil of the cell towards adjacent cells via subsurface flow (in mm).
InterflowBalance
: The balance of water circulating via subsurface flow (in mm).
BaseflowInput
: The amount of water that reaches the aquifer of the cell from adjacent cells via groundwater flow (in mm).
BaseflowOutput
: The amount of water that leaves the aquifer of the cell towards adjacent cells via groundwater flow (in mm).
BaseflowBalance
: The balance of water circulating via groundwater flow (in mm).
AquiferExfiltration
: The amount of water of the cell that generates surface runoff due to the aquifer reaching the soil surface (in mm).
SWE
: Snow water equivalent (in mm) of the snowpack.
RWC
: Soil relative water content with respect to field capacity (in percent).
SoilVol
: Soil water volume integrated across vertical layers (in mm).
WTD
: Saturated soil water table depth (in mm from surface).
DTA
: Depth to aquifer (in m from surface).
result
: A list of cell detailed results (only for those indicated in the input), with contents depending on the local model.
outlet
: A logical vector indicating outlet cells.
In function fordyn_land
the sf
object contains additional columns:
forest
: A list of forest
objects for each simulated stand, to be used in subsequent simulations (see update_landscape
).
management_arguments
: A list of management arguments for each simulated stand, to be used in subsequent simulations (see update_landscape
).
tree_table
: A list of data frames for each simulated stand, containing the living trees at each time step.
shrub_table
: A list of data frames for each simulated stand, containing the living shrub at each time step.
dead_tree_table
: A list of data frames for each simulated stand, containing the dead trees at each time step.
dead_shrub_table
: A list of data frames for each simulated stand, containing the dead shrub at each time step.
cut_tree_table
: A list of data frames for each simulated stand, containing the cut trees at each time step.
cut_shrub_table
: A list of data frames for each simulated stand, containing the cut shrub at each time step.
watershed_balance
: A data frame with as many rows as days and where columns are components of the water balance at the watershed level (i.e., rain, snow, interception, infiltration, soil evaporation, plant transpiration, ...).
watershed_soil_balance
: A data frame with as many rows as days and where columns are components of the water balance at the watershed level restricted to those cells with a soil definition.
outlet_export_m3s
: A matrix with daily values of runoff (in m3/s) reaching each of the outlet cells of the landscape. Each outlet drains its own subset of cells, so the
overall watershed export corresponds to the sum of row values.
Miquel De Cáceres Ainsa, CREAF.
Maria González-Sanchís, Universitat Politecnica de Valencia.
Daniel Caviedes-Voullième, Forschungszentrum Julich.
Mario Morales-Hernández, Universidad de Zaragoza.
Francés, F., Vélez, J.I. & Vélez, J.J. (2007). Split-parameter structure for the automatic calibration of distributed hydrological models. Journal of Hydrology, 332, 226–240.
Caviedes-Voullième, D., Morales-Hernández, M., Norman, M.R. & Ogzen-Xian, I. (2023). SERGHEI (SERGHEI-SWE) v1.0: a performance-portable high-performance parallel-computing shallow-water solver for hydrology and environmental hydraulics. Geoscientific Model Development, 16, 977-1008.
default_watershed_control
, initialize_landscape
, spwb_land_day
, spwb_day
, growth_day
,
spwb_spatial
, fordyn_spatial
, dispersal
# Load example watershed data data("example_watershed") # Set crop factor example_watershed$crop_factor <- NA example_watershed$crop_factor[example_watershed$land_cover_type=="agriculture"] <- 0.75 # Set request for daily model results in cells number 3, 6 (outlet) and 9 example_watershed$result_cell <- FALSE example_watershed$result_cell[c(3,6,9)] <- TRUE # Get bounding box to determine limits b <- sf::st_bbox(example_watershed) b # Define a raster topology, using terra package, # with the same CRS as the watershed. In this example cells have 100 m side. # Coordinates in the 'sf' object are assumed to be cell centers r <-terra::rast(xmin = 401380, ymin = 4671820, xmax = 402880, ymax = 4672620, nrow = 8, ncol = 15, crs = "epsg:32631") # Load example meteo data frame from package meteoland data("examplemeteo") # Load default medfate parameters data("SpParamsMED") # Set simulation period dates <- seq(as.Date("2001-01-01"), as.Date("2001-03-31"), by="day") # Watershed control parameters (TETIS model; Frances et al. 2007) ws_control <- default_watershed_control("tetis") # Launch simulations res <- spwb_land(r, example_watershed, SpParamsMED, examplemeteo, dates = dates, summary_frequency = "month", watershed_control = ws_control) # Print a summary of water balance components summary(res) # Option 'simplify = TRUE' in initialization, may be useful to speed up calculations example_simplified <- initialize_landscape(example_watershed, SpParams = SpParamsMED, local_control = defaultControl(soilDomains = "single"), simplify = TRUE) # Launch simulations over simplified landscape (should be considerably faster) res_simplified <- spwb_land(r, example_simplified, SpParamsMED, examplemeteo, dates = dates, summary_frequency = "month", watershed_control = ws_control)
# Load example watershed data data("example_watershed") # Set crop factor example_watershed$crop_factor <- NA example_watershed$crop_factor[example_watershed$land_cover_type=="agriculture"] <- 0.75 # Set request for daily model results in cells number 3, 6 (outlet) and 9 example_watershed$result_cell <- FALSE example_watershed$result_cell[c(3,6,9)] <- TRUE # Get bounding box to determine limits b <- sf::st_bbox(example_watershed) b # Define a raster topology, using terra package, # with the same CRS as the watershed. In this example cells have 100 m side. # Coordinates in the 'sf' object are assumed to be cell centers r <-terra::rast(xmin = 401380, ymin = 4671820, xmax = 402880, ymax = 4672620, nrow = 8, ncol = 15, crs = "epsg:32631") # Load example meteo data frame from package meteoland data("examplemeteo") # Load default medfate parameters data("SpParamsMED") # Set simulation period dates <- seq(as.Date("2001-01-01"), as.Date("2001-03-31"), by="day") # Watershed control parameters (TETIS model; Frances et al. 2007) ws_control <- default_watershed_control("tetis") # Launch simulations res <- spwb_land(r, example_watershed, SpParamsMED, examplemeteo, dates = dates, summary_frequency = "month", watershed_control = ws_control) # Print a summary of water balance components summary(res) # Option 'simplify = TRUE' in initialization, may be useful to speed up calculations example_simplified <- initialize_landscape(example_watershed, SpParams = SpParamsMED, local_control = defaultControl(soilDomains = "single"), simplify = TRUE) # Launch simulations over simplified landscape (should be considerably faster) res_simplified <- spwb_land(r, example_simplified, SpParamsMED, examplemeteo, dates = dates, summary_frequency = "month", watershed_control = ws_control)
Functions to perform one-day simulations on a watershed described by a set of connected grid cells.
Function spwb_land_day
implements a distributed hydrological model that simulates daily local water balance, from spwb_day
,
on grid cells of a watershed while accounting for overland runoff, subsurface flow and groundwater flow between cells.
Function growth_land_day
is similar to spwb_land_day
, but includes daily local carbon balance, growth and mortality processes in grid cells,
provided by growth_day
.
spwb_land_day( r, sf, SpParams, meteo = NULL, date = NULL, local_control = medfate::defaultControl(soilDomains = "single"), watershed_control = default_watershed_control(), parallelize = FALSE, num_cores = parallel::detectCores() - 1, chunk_size = NULL, progress = TRUE ) growth_land_day( r, sf, SpParams, meteo = NULL, date = NULL, local_control = medfate::defaultControl(soilDomains = "single"), watershed_control = default_watershed_control(), parallelize = FALSE, num_cores = parallel::detectCores() - 1, chunk_size = NULL, progress = TRUE )
spwb_land_day( r, sf, SpParams, meteo = NULL, date = NULL, local_control = medfate::defaultControl(soilDomains = "single"), watershed_control = default_watershed_control(), parallelize = FALSE, num_cores = parallel::detectCores() - 1, chunk_size = NULL, progress = TRUE ) growth_land_day( r, sf, SpParams, meteo = NULL, date = NULL, local_control = medfate::defaultControl(soilDomains = "single"), watershed_control = default_watershed_control(), parallelize = FALSE, num_cores = parallel::detectCores() - 1, chunk_size = NULL, progress = TRUE )
r |
An object of class |
sf |
|
SpParams |
A data frame with species parameters (see |
meteo |
Input meteorological data (see |
date |
A string with the date to be simulated. |
local_control |
A list of control parameters (see |
watershed_control |
A list of watershed control parameters (see |
parallelize |
Boolean flag to try parallelization (see details). |
num_cores |
Integer with the number of cores to be used for parallel computation (by default it will use all clusters minus one). |
chunk_size |
Integer indicating the size of chunks to be sent to different processes (by default, the number of spatial elements divided by the number of cores). |
progress |
Boolean flag to display progress information for simulations. |
See details in spwb_land
.
Functions spwb_land_day
and spwb_land_day
return a sf object:
geometry
: Spatial geometry.
state
: A list of model input objects for each simulated stand.
aquifer
: A numeric vector with the water volume in the aquifer of each cell.
snowpack
: A numeric vector with the snowpack water equivalent volume of each cell.
result
: A list of cell detailed results (only for those indicated in the input), with contents depending on the local model.
outlet
: A logical vector indicating outlet cells.
MinTemperature
: Minimum temperature (degrees Celsius).
MaxTemperature
: Maximum temperature (degrees Celsius).
PET
: Potential evapotranspiration (in mm).
Rain
: Rainfall (in mm).
Snow
: Snowfall (in mm).
Snowmelt
: Snow melt (in mm).
Interception
: Rainfall interception (in mm).
NetRain
: Net rainfall, i.e. throughfall, (in mm).
Infiltration
: The amount of water infiltrating into the soil (in mm).
InfiltrationExcess
: The amount of water exceeding the soil infiltration capacity (in mm).
SaturationExcess
: The amount of water that reaches the soil surface because of soil saturation (in mm).
Runoff
: The amount of water exported via surface runoff (in mm).
DeepDrainage
: The amount of water draining from soil to the aquifer via deep drainage (in mm).
CapillarityRise
: Water entering the soil via capillarity rise (mm) from the water table.
SoilEvaporation
: Bare soil evaporation (in mm).
Transpiration
: Woody plant transpiration (in mm).
HerbTranspiration
: Herbaceous transpiration (in mm).
InterflowInput
: The amount of water that reaches the soil of the cell from adjacent cells via subsurface flow (in mm).
InterflowOutput
: The amount of water that leaves the soil of the cell towards adjacent cells via subsurface flow (in mm).
InterflowBalance
: The balance of water circulating via subsurface flow (in mm).
BaseflowInput
: The amount of water that reaches the aquifer of the cell from adjacent cells via groundwater flow (in mm).
BaseflowOutput
: The amount of water that leaves the aquifer of the cell towards adjacent cells via groundwater flow (in mm).
BaseflowBalance
: The balance of water circulating via groundwater flow (in mm).
AquiferExfiltration
: The amount of water of the cell that generates surface runoff due to the aquifer reaching the soil surface (in mm).
Miquel De Cáceres Ainsa, CREAF.
Maria González-Sanchís, Universitat Politecnica de Valencia.
Daniel Caviedes-Voullième, Forschungszentrum Julich.
Mario Morales-Hernández, Universidad de Zaragoza.
Francés, F., Vélez, J.I. & Vélez, J.J. (2007). Split-parameter structure for the automatic calibration of distributed hydrological models. Journal of Hydrology, 332, 226–240.
Caviedes-Voullième, D., Morales-Hernández, M., Norman, M.R. & Ogzen-Xian, I. (2023). SERGHEI (SERGHEI-SWE) v1.0: a performance-portable high-performance parallel-computing shallow-water solver for hydrology and environmental hydraulics. Geoscientific Model Development, 16, 977-1008.
default_watershed_control
, spwb_day
, growth_day
,
spwb_land
,
# Load example watershed data after burnin period data("example_watershed_burnin") # Set request for daily model results in cells number 3, 6 (outlet) and 9 example_watershed_burnin$result_cell <- FALSE example_watershed_burnin$result_cell[c(3,6,9)] <- TRUE # Get bounding box to determine limits b <- sf::st_bbox(example_watershed_burnin) b # Define a raster topology, using terra package, # with the same CRS as the watershed. In this example cells have 100 m side. # Coordinates in the 'sf' object are assumed to be cell centers r <-terra::rast(xmin = 401380, ymin = 4671820, xmax = 402880, ymax = 4672620, nrow = 8, ncol = 15, crs = "epsg:32631") # Load example meteo data frame from package meteoland data("examplemeteo") # Load default medfate parameters data("SpParamsMED") # Watershed control parameters (TETIS model; Frances et al. 2007) ws_control <- default_watershed_control("tetis") # Launch simulation date <- "2001-03-01" sf_out <- spwb_land_day(r, example_watershed_burnin, SpParamsMED, examplemeteo, date = date, watershed_control = ws_control)
# Load example watershed data after burnin period data("example_watershed_burnin") # Set request for daily model results in cells number 3, 6 (outlet) and 9 example_watershed_burnin$result_cell <- FALSE example_watershed_burnin$result_cell[c(3,6,9)] <- TRUE # Get bounding box to determine limits b <- sf::st_bbox(example_watershed_burnin) b # Define a raster topology, using terra package, # with the same CRS as the watershed. In this example cells have 100 m side. # Coordinates in the 'sf' object are assumed to be cell centers r <-terra::rast(xmin = 401380, ymin = 4671820, xmax = 402880, ymax = 4672620, nrow = 8, ncol = 15, crs = "epsg:32631") # Load example meteo data frame from package meteoland data("examplemeteo") # Load default medfate parameters data("SpParamsMED") # Watershed control parameters (TETIS model; Frances et al. 2007) ws_control <- default_watershed_control("tetis") # Launch simulation date <- "2001-03-01" sf_out <- spwb_land_day(r, example_watershed_burnin, SpParamsMED, examplemeteo, date = date, watershed_control = ws_control)
Functions that allow calling local models spwb
, growth
or fordyn
, for a set of forest stands distributed in specific locations.
No spatial processes are simulated.
spwb_spatial( sf, SpParams, meteo = NULL, local_control = defaultControl(), dates = NULL, CO2ByYear = numeric(0), keep_results = TRUE, summary_function = NULL, summary_arguments = NULL, parallelize = FALSE, num_cores = detectCores() - 1, chunk_size = NULL, progress = TRUE, local_verbose = FALSE ) growth_spatial( sf, SpParams, meteo = NULL, local_control = defaultControl(), dates = NULL, CO2ByYear = numeric(0), fire_regime = NULL, keep_results = TRUE, summary_function = NULL, summary_arguments = NULL, parallelize = FALSE, num_cores = detectCores() - 1, chunk_size = NULL, progress = TRUE, local_verbose = FALSE ) fordyn_spatial( sf, SpParams, meteo = NULL, local_control = defaultControl(), dates = NULL, CO2ByYear = numeric(0), fire_regime = NULL, keep_results = TRUE, management_function = NULL, summary_function = NULL, summary_arguments = NULL, parallelize = FALSE, num_cores = detectCores() - 1, chunk_size = NULL, progress = TRUE, local_verbose = FALSE )
spwb_spatial( sf, SpParams, meteo = NULL, local_control = defaultControl(), dates = NULL, CO2ByYear = numeric(0), keep_results = TRUE, summary_function = NULL, summary_arguments = NULL, parallelize = FALSE, num_cores = detectCores() - 1, chunk_size = NULL, progress = TRUE, local_verbose = FALSE ) growth_spatial( sf, SpParams, meteo = NULL, local_control = defaultControl(), dates = NULL, CO2ByYear = numeric(0), fire_regime = NULL, keep_results = TRUE, summary_function = NULL, summary_arguments = NULL, parallelize = FALSE, num_cores = detectCores() - 1, chunk_size = NULL, progress = TRUE, local_verbose = FALSE ) fordyn_spatial( sf, SpParams, meteo = NULL, local_control = defaultControl(), dates = NULL, CO2ByYear = numeric(0), fire_regime = NULL, keep_results = TRUE, management_function = NULL, summary_function = NULL, summary_arguments = NULL, parallelize = FALSE, num_cores = detectCores() - 1, chunk_size = NULL, progress = TRUE, local_verbose = FALSE )
sf |
An object of class
|
SpParams |
A data frame with species parameters (see |
meteo |
Input meteorological data (see section details). If NULL, the function will expect a column 'meteo' in parameter |
local_control |
A list of control parameters (see |
dates |
A |
CO2ByYear |
A named numeric vector with years as names and atmospheric CO2 concentration (in ppm) as values. Used to specify annual changes in CO2 concentration along the simulation (as an alternative to specifying daily values in |
keep_results |
Boolean flag to indicate that point/cell simulation results are to be returned (set to |
summary_function |
An appropriate function to calculate summaries (e.g., |
summary_arguments |
List with additional arguments for the summary function. |
parallelize |
Boolean flag to try parallelization (will use all clusters minus one). |
num_cores |
Integer with the number of cores to be used for parallel computation. |
chunk_size |
Integer indicating the size of chuncks to be sent to different processes (by default, the number of spatial elements divided by the number of cores). |
progress |
Boolean flag to display progress information of simulations. |
local_verbose |
Boolean flag to display detailed progress information in local simulations. |
fire_regime |
A list of parameters defining the fire regime (see |
management_function |
A function that implements forest management actions (see |
Simulation functions accept different formats for meteorological input (parameter meteo
).
The user may supply two kinds of daily weather sources:
A data frame with meteorological data common for all spatial location (spatial variation of weather not considered).
An object or (a list of objects) of class stars
with reference interpolation data created by package meteoland
.
If a list of such interpolator objects is supplied, the simulation functions will interpolate on the target locations for the periods covered by each interpolator,
but the user will be responsible for supplying interpolators in the correct temporal order.
Alternatively, the user may leave parameter meteo = NULL
and specify a weather data frame for each element of y
in a column named 'meteo'.
Fire regimes are only allowed for function fordyn_spatial
. If an object of class fire_regime
is supplied, the function will call
fire_regime_instance
to generate a realization of the fire regime before conducting simulations. Alternatively,
users can directly supply a fire regime instance matrix, derived from another source (e.g. a fire landscape model). Note that operating
with fire regimes assumes all forest stands share the same period of simulation, but enforcing this is left to the user.
An object of class 'sf' containing four elements:
geometry
: Spatial geometry.
id
: Stand id, taken from the input.
state
: A list of spwbInput
or growthInput
objects for each simulated stand, to be used in subsequent simulations (see update_landscape
) or with NULL values whenever simulation errors occurred.
forest
: A list of forest
objects for each simulated stand (only in function fordyn_spatial
), to be used in subsequent simulations (see update_landscape
) or with NULL values whenever simulation errors occurred.
management_arguments
: A list of management arguments for each simulated stand (only in function fordyn_spatial
if management function was supplied), to be used in subsequent simulations (see update_landscape
).
result
: A list of model output for each simulated stand. Some elements can contain an error condition if the simulation resulted in an error. Values will be NULL (or errors) if keep_results = FALSE
.
summary
: A list of model output summaries for each simulated stand (if summary_function
was not NULL
), with NULL values whenever simulation errors occurred.
Miquel De Cáceres Ainsa, CREAF
spwb
, growth
, fordyn
, spwb_spatial_day
,
simulation_summary
, plot_summary
,
initialize_landscape
, update_landscape
# Load example landscape data data("example_ifn") # Load example meteo data frame from package meteoland data("examplemeteo") # Load default medfate parameters data("SpParamsMED") # Subset two plots to speed-up calculations example_subset <- example_ifn[31:32, ] # Perform simulation dates <- seq(as.Date("2001-03-01"), as.Date("2001-03-15"), by="day") res <- spwb_spatial(example_subset, SpParamsMED, examplemeteo, dates = dates) # Perform fordyn simulation for one year (one stand) without management res_noman <- fordyn_spatial(example_subset, SpParamsMED, examplemeteo)
# Load example landscape data data("example_ifn") # Load example meteo data frame from package meteoland data("examplemeteo") # Load default medfate parameters data("SpParamsMED") # Subset two plots to speed-up calculations example_subset <- example_ifn[31:32, ] # Perform simulation dates <- seq(as.Date("2001-03-01"), as.Date("2001-03-15"), by="day") res <- spwb_spatial(example_subset, SpParamsMED, examplemeteo, dates = dates) # Perform fordyn simulation for one year (one stand) without management res_noman <- fordyn_spatial(example_subset, SpParamsMED, examplemeteo)
Functions that allow calling local models spwb_day
or growth_day
,
for a set of forest stands distributed in specific locations and a given date.
No spatial processes are simulated.
spwb_spatial_day( sf, meteo = NULL, date, SpParams, local_control = defaultControl(), parallelize = FALSE, num_cores = detectCores() - 1, chunk_size = NULL, progress = TRUE ) growth_spatial_day( sf, meteo = NULL, date, SpParams, local_control = defaultControl(), parallelize = FALSE, num_cores = detectCores() - 1, chunk_size = NULL, progress = TRUE )
spwb_spatial_day( sf, meteo = NULL, date, SpParams, local_control = defaultControl(), parallelize = FALSE, num_cores = detectCores() - 1, chunk_size = NULL, progress = TRUE ) growth_spatial_day( sf, meteo = NULL, date, SpParams, local_control = defaultControl(), parallelize = FALSE, num_cores = detectCores() - 1, chunk_size = NULL, progress = TRUE )
sf |
An object of class |
meteo |
Meteorology data (see |
date |
A string with the date to be simulated. |
SpParams |
A data frame with species parameters (see |
local_control |
A list of local model control parameters (see |
parallelize |
Boolean flag to try parallelization (will use all clusters minus one). |
num_cores |
Integer with the number of cores to be used for parallel computation. |
chunk_size |
Integer indicating the size of chunks to be sent to different processes (by default, the number of spatial elements divided by the number of cores). |
progress |
Boolean flag to display progress information for simulations. |
Simulation functions accept different formats for meteorological input (described in spwb_spatial
).
An object of class sf
the same name as the function called containing three elements:
geometry
: Spatial geometry.
id
: Stand id, taken from the input.
state
: A list of model input objects for each simulated stand, to be used in subsequent simulations.
result
: A list of model output for each simulated stand.
Miquel De Cáceres Ainsa, CREAF
spwb_day
, growth_day
, spwb_spatial
#Load example landscape data data("example_ifn") #Load example meteo data frame from package meteoland data("examplemeteo") #Load default medfate parameters data("SpParamsMED") #Perform simulation date <- "2001-03-01" res <- spwb_spatial_day(example_ifn, examplemeteo, date, SpParamsMED)
#Load example landscape data data("example_ifn") #Load example meteo data frame from package meteoland data("examplemeteo") #Load default medfate parameters data("SpParamsMED") #Perform simulation date <- "2001-03-01" res <- spwb_spatial_day(example_ifn, examplemeteo, date, SpParamsMED)
Updates the state of a spatial object 'x' according to the final state in simulation outcome 'y'
update_landscape(x, y)
update_landscape(x, y)
x |
An object of class |
y |
The object resulting of a simulation previously carried on |
An object of class sf
with modified state variables.
Miquel De Cáceres Ainsa, CREAF.
spwb_spatial
, spwb_spatial_day
, spwb_land