Skip to contents

Create a section cross profile from a DEM

Usage

dem_to_section(dem, node_coords, section_center, 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

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)
reach_txt[[5]]
#>  [1] "Major x=400 $ 400 $ 100 $ 1 $ A"   "0\t44.5943017256092"               
#>  [3] "102.040816326524\t43.8289874203584" "204.081632653062\t42.9885541120967"
#>  [5] "306.122448979586\t42.0812732368117" "408.163265306124\t41.1197226082103"
#>  [7] "510.204081632648\t40.1203649469581" "612.244897959186\t39.1025765242363"
#>  [9] "714.28571428571\t38.0873175040893"  "816.326530612248\t37.0953458485321"
#> [11] "918.367346938772\t36.1454523399178" "1020.40816326531\t35.2532342061862"
#> [13] "1122.44897959183\t34.4302509819152" "1224.48979591837\t33.6837352493296"
#> [15] "1326.5306122449\t33.0168010276359"  "1428.57142857143\t32.429014824396" 
#> [17] "1530.61224489796\t31.9171657488752" "1632.6530612245\t31.4760854855401" 
#> [19] "1734.69387755102\t31.0994082192573" "1836.73469387754\t30.780206429748" 
#> [21] "1938.77551020408\t30.5116122476672" "2040.81632653061\t30.2867893668675"
#> [23] "2142.85714285714\t30.0994054372091" "2244.89795918367\t29.9438256669469"
#> [25] "2346.93877551021\t29.8150647208602" "2448.97959183673\t29.4924862659348"
#> [27] "2551.02040816327\t28.3066326530615" "2653.06122448979\t29.7870966396955"
#> [29] "2755.10204081633\t29.9099700636394" "2857.14285714286\t30.0585391911062"
#> [31] "2959.18367346939\t30.2376293209911" "3061.22448979592\t30.4527178275355"
#> [33] "3163.26530612246\t30.7099932039774" "3265.30612244898\t31.0161853566989"
#> [35] "3367.3469387755\t31.3781275865191"  "3469.38775510204\t31.8028048100129"
#> [37] "3571.42857142857\t32.2967737438126" "3673.4693877551\t32.8655625939493" 
#> [39] "3775.51020408163\t33.5129373690372" "3877.55102040817\t34.240088248869" 
#> [41] "3979.59183673469\t35.0448346610494" "4081.63265306123\t35.9209901577524"
#> [43] "4183.67346938775\t36.8580505366603" "4285.71428571429\t37.8413519101458"
#> [45] "4387.75510204081\t38.85278305705"   "4489.79591836735\t39.8719161739924"
#> [47] "4591.83673469388\t40.8776588589341" "4693.87755102041\t41.8501251788203"
#> [49] "4795.91836734694\t42.7720281211562" "4897.95918367348\t43.6297766142547"
#> [51] "5000\t44.4140336149618"            
#> attr(,"class")
#> [1] "SectionTxt" "character"