# rmarkdown::pdf_document
# rmarkdown::html_vignette
knitr::opts_chunk$set(fig.width = 15, fig.height = 10, eval = TRUE)
file.copy(system.file("extdata", "testELEV.dbf", package = "LITAP"), ".", 
          overwrite = TRUE)

Basic run

First load the LITAP package:

library(LITAP)

Here we will use the "testELEV.dbf" included in the package. You can copy it to your working directory with:

file.copy(system.file("extdata", "testELEV.dbf", package = "LITAP"), ".")

The only required parameters are the location of the dem file (file) and the number of rows and the number of columns (nrow and ncol) in the dem file.

flow_mapper(file = "testELEV.dbf", nrow = 90, ncol = 90, grid = 5)

Pit removal parameters

The maximum size of initial watersheds which will be removed in the first step can also be specified:

flow_mapper(file = "testELEV.dbf", nrow = 90, ncol = 90, grid = 5,
            max_area = 5, max_depth = 0.2)

Output folders

A LITAP run saves all output from flow_mapper() into folder flow.

You can specify where these output folders/files should be saved with out_folder. Otherwise the folders will be created in the folder of the original Elev.dbf file, which may not be desirable.

flow_mapper(file = "testELEV.dbf", nrow = 90, ncol = 90, grid = 5, 
            out_folder = "./LITAP runs/")

Ideally, it's best to create an RStudio project, put the original Elev.dbf file in this project and work from there. Note that folder locations are relative to working directory of the R session.

To clean up any old files before conducting a new run, use clean = TRUE. Careful, this will remove all backup files from previous runs making it impossible to resume a run!

flow_mapper(file = "testELEV.dbf", nrow = 90, ncol = 90, grid = 5,
            out_folder = "./LITAP runs/", clean = TRUE)

Different input file types

You can use a variety of input file types, provided they fit the format specifications defined in load_file() (?load_file for more details). Among others, the following file types are accepted:

flow_mapper(file = "testELEV.grd") # Grid files
flow_mapper(file = "testELEV.csv") # CSV files
flow_mapper(file = "testELEV.asc") # Ascii Grid files
flow_mapper(file = "testELEV.flt") # Floating point raster files
flow_mapper(file = "testELEV")     # ArcGis Gridfile folder (contains .hdr files)

Subset of input dem

To conduct a run on only a subset of the dem you can specify row and column limits (rlim and clim respectively):

flow_mapper(file = "testELEV.dbf", nrow = 90, ncol = 90, grid = 5,
            rlim = c(50,80), clim = c(50,80))

Output messages

To include detailed output, use verbose = TRUE:

flow_mapper(file = "testELEV.dbf", nrow = 90, ncol = 90, grid = 5, verbose = TRUE)

To prevent all output, use quiet = TRUE:

flow_mapper(file = "testELEV.dbf", nrow = 90, ncol = 90, grid = 5, quiet = TRUE)

Resuming a run

Each run of LITAP goes through numerous steps. If there's a problem, a run can be resumed at step by specifying the corresponding variable.

For example, to resume with calculating pond statistics and continue to the end of the run:

flow_mapper(file = "testELEV.dbf", nrow = 90, ncol = 90, grid = 5,
            resume = "pond")

Note that if a run finishes, you won't be able to resume that run from a previous step, as intermediate files are removed. If you want this ability, use the argument debug = TRUE.

Steps

The variable in brackets defines the argument to use for continuing and ending a run.

  1. Calculating Directions (directions) Calculating the flow direction of each cell into a neighbouring cell

  2. Calculating Watersheds (watersheds) From the flow directions, combine cells into initial watersheds

  3. Initial Pit Removal (local) Remove pits which are smaller than the maximum area and depth (and which are not edge pits). These pits are removed into neighbouring pits.

  4. Calculating Pond Shed Statistics Second Pit Removal) (pond) Calculate how pits would overflow into each other

  5. Calculating Fill Shed Statistics (Third Pit Removal) (fill)

  6. Calculating Directions on Inverted DEM (idirections) Reverse the elevations of the original DEM file. This will make all troughs into peaks, etc. Then calculate the flow direction of each cell into a neighbouring cell. Because the DEM is inverted, this will track upslope flow

  7. Calculating Inverted Watersheds (iwatersheds) From the flow directions, combine cells into initial watersheds

  8. Initial Inverted Pit Removal (ilocal) Remove pits which are smaller than the maximum area and depth (and which are not edge pits). These pits are removed into neighbouring pits. Calculate watershed statistics on these resulting local pits. Because the DEM is inverted, this will highlight peaks and flow down from these peaks.

unlink("./testELEV.dbf")
unlink("./testELEV/", recursive = TRUE)
unlink("./LITAP runs/", recursive = TRUE)


steffilazerte/LITAP documentation built on Feb. 9, 2022, 8:11 a.m.