knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(TerrainWorksUtils)

This package includes some methods from the DEM utilities toolbox. You can calculate slope metrics which can be used as model inputs. These methods are currently only supported on Windows.

Available metrics include:

Surface metrics can be calculated over a scale which is greater than the resolution of the DEM, which can add some smoothing to the output. The default is a 15-meter scale.

Let's say you want to calculate gradient, plan curvature, and profile curvature to use as inputs for a landslide susceptibility model. The example DEM which comes with this package is at a 20-meter scale, so we will calculate the metrics over a 40-meter scale.

Let's create a temporary output directory to put the files. In your workflow, you should save them somewhere that makes sense, like the same directory as the DEM.

DEM_path <- system.file("elev_scottsburg/elev_scottsburg.flt", 
                        package = "TerrainWorksUtils")
output_dir <- "\\\\Mac/Home/Documents/terrainworks/code/TerrainWorksUtils/inst/elev_scottsburg"
metrics <- c("plan", "grad", "prof", "dev")
calculate_surface_metrics(metrics = metrics, 
                          DEM_path = DEM_path, 
                          output_dir = output_dir, 
                          length_scale = 15)

This will have written rasters to the output directory for plan curvature, gradient, and profile curvature based on the DEM. They are written both as .flt files and as .tif files.

list.files(output_dir)

The input file used to run the executable is also saved to the output directory: input_makeGrids.txt. You can examine this file to help with debugging.



tabrasel/WetlandTools documentation built on Dec. 20, 2024, 8:50 a.m.