Create a section cross profile from a DEM
dem_to_section.Rd
Create a section cross profile from a DEM
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
- section_center
2-lenght numeric, coordinates of the section center
- section_width
1-length numeric, width of the sections to create
- nb_points
1-length numeric, number of points to describe cross-section geometries
Value
A matrix with the coordinates of the x-z points in the cross-profile section referential
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