Skip to contents

The coordinate system of dem should be a metric orthonormal coordinate system.

Usage

dem_to_reach_txt(
  dem,
  node_coords,
  space_step,
  section_width,
  nb_points = 50,
  start = 0,
  major_bed = FALSE
)

dem_to_reach(dem, node_coords, section_centers, section_width, nb_points = 50)

Arguments

dem

terra::SpatRaster object with altitude data (m).

node_coords

a 2x2 matrix with coordinates of starting and ending points of the line to browse

space_step

1-length numeric, distance between each section (m)

section_width

1-length numeric, width of the sections to create

nb_points

1-length numeric, number of points to describe cross-section geometries

start

1-length numeric, starting value for the chainage (i.e. section abscissa) along the reach

major_bed

logical, TRUE for major bed, FALSE for minor-medium bed

section_centers

See return value of get_section_centers

Value

A ReachTxt object which is a list of SectionTxt objects (see create_section_txt).

Examples

## Inputs preparation
data("floodam_ead_dem")
dem <- terra::rast(floodam_ead_dem)
node_coords <- matrix(c(102550, 102550, 110000, 108000), ncol = 2)
space_step = 100
section_width = 5000

## Get section positions
reach_length <- as.numeric(dist(node_coords[1:2,]))
nb_sections <- ceiling(reach_length / space_step) + 1
section_centers <- get_section_centers(node_coords, nb_sections)

## Create a section profile and plot it!
profile <- dem_to_section(dem, node_coords, section_centers[5,], section_width)
plot(profile)


## Generate cross section profiles for a reach
reach <- dem_to_reach(dem, node_coords, section_centers, section_width)
plot(reach[[5]])

## Generate section profiles in SIC import text format
reach_txt <- dem_to_reach_txt(dem, node_coords, space_step, section_width, major_bed = TRUE)
#> Warning: 'x' is NULL so the result will be NULL
#> Error in ans[ypos] <- rep(yes, length.out = len)[ypos]: replacement has length zero
reach_txt[[5]]
#> Error: object 'reach_txt' not found