R6 Class for processing a catchment to make a dynatop TOPMODEL
dynatopGIS$new()Initialise a project, or reopen an existing project
dynatopGIS$new(projectDir)dynatopGIS$add_catchment()Add a catchment outline and dem to the `dynatopGIS` project
catchmenta SpatVect object or the path to file containing one which contains the catchment outline
dema SpatRast object or the path to file containing one which is the DEM
fill_navalue used to replace missing dem vales within the catchment
dynatopGIS$add_channel()Import channel data to the `dynatopGIS` object
channela SpatVect object of lines or file path that can be loaded as one containing the channel information
water_bodiesa SpatVect object of polygons or file path that can be loaded as one containing the channel information
verboseShould additional progress information be printed
dynatopGIS$add_layer()Add a layer of geographical information
dynatopGIS$add_layer(layer, layer_name = names(layer))The layer should either be a raster layer or a file that can be read into a SpatRast by the terra package. The projection, resolution and extent are checked against the existing project data. Only layer names not already in use (or reserved) are allowed. If successful the layer is added to the project.
dynatopGIS$sink_fill()The sink filling algorithm of Planchona and Darboux (2001)
min_gradMinimum gradient between cell centres
max_itmaximum number of replacement cycles
verboseprint out additional diagnostic information
hot_startstart from filled_dem if it exists
The algorithm implemented is based on that described in Planchona and Darboux, "A fast, simple and versatile algorithm to fill the depressions in digital elevation models" Catena 46 (2001). A pdf can be found at (<https://horizon.documentation.ird.fr/exl-doc/pleins_textes/pleins_textes_7/sous_copyright/010031925.pdf>).
The flow_type can be either MFD algorithm in TODO
dynatopGIS$combine_layers()Combine any number of layers into a unique classification
dynatopGIS$create_model()Create a Dynamic TOPMODEL
dynatopGIS$create_model(
model_name,
class_layer = NULL,
precip_layer = NULL,
precip_label = "precip",
pet_layer = NULL,
pet_label = "pet",
verbose = FALSE
)model_namebase of the name for the new model files
class_layerthe layer defining the landscape classes
precip_layerthe layer defining the rainfall inputs
precip_labelPrepended to rain_layer values to give rainfall series name
pet_layerthe layer defining the pet inputs
pet_labelPrepended to pet_layer values to give pet series name
verboseprint more details of progress
The class_layer is used to assign classes to the HRUs. Flow between HRUs are based on the ordering of the catchment (see the order method) with low from a HRU can only go to a HRU with a lower band.
The rain_layer (pet_layer) can contain the numeric id values of different rainfall (pet) series. If the value of rain_layer (pet_layer) is not NULL the value for the precipitation and PET inputs for each HRU are taken as e.g. paste0(precip_label,precip) otherwise the value of e.g. precip_label is used. The model_name can contain the path to the files.
## The vignettes contains more examples of the method calls.
## create temporary directory for output
demo_dir <- tempfile("dygis")
dir.create(demo_dir)
## locate the dem, channel and catchment outline files
chnFile <- system.file("extdata", "gis", "SwindaleRiverNetwork.gpkg",
package="dynatop", mustWork = TRUE)
demFile <- system.file("extdata", "gis", "SwindaleDTM.tif",
package="dynatop", mustWork = TRUE)
ctchFile <- system.file("extdata", "gis", "SwindaleBoundary.gpkg",
package="dynatop", mustWork = TRUE)
## Preprocess channel data
chn <- terra::vect(chnFile)
chn$slope <- 1e-3
chn$class <- 1
chn$width <- 1
chn$depth <- 0.1
chn <- convert_channel(chn,
property_names=c(uid = "identifier",
startNode = "startNode",
endNode = "endNode",
slope = "slope",
class = "class",
width="width",
depth="depth"))
chn <- simplify_channel(chn)
## create a project
dy <- dynatopGIS$new(demo_dir)
## add dem and catchment data
dy$add_catchment(ctchFile, demFile)
## add the channel
dy$add_channel(chn)
## fill the sinks
dy$sink_fill()
## compute the order
dy$order()
## add a new layer
tmp <- dy$get_layer("filled_dem")
tmp <- terra::classify(tmp,5)
names(tmp) <- "alt_band"
dy$add_layer(tmp)
## classify the layer
dy$combine_layers("class_alt_band","alt_band")
## build a model
# \donttest{
dy$create_model(file.path(demo_dir,"new_model"),"class_alt_band") ## create a model
list.files(demo_dir,pattern="new_model*") ## look at the output files for the model
#> [1] "new_model.gpkg" "new_model_param.json"
# }
## tidy up
unlink(demo_dir)