Skip to contents

Calculate cross sections from banklines that are roughly equally spaced apart.

Usage

xt_generate_sxc(bankline, n)

Arguments

bankline

An sf object with banklines.

n

The number of cross sections to calculate.

Value

An "sxc" object.

Details

This function takes the definition of "cross section" relative to a point in the channel to be the line segment intersecting the point whose bank-to-bank segment width is the smallest. Note that this does not imply that the cross section is unique, and in this case the cross section is arbitrarily taken to be the one closest to a 0-degree angle – although in almost all cases this should not be an issue.

To define the spacing of the cross sections, a centerline is first calculated, and equally spaced points are sampled along the centerline. Cross sections are calculated at these points. Note that cross sections are not a necessary part of choosing cross section spacing, but it is useful.

Note

The function the calculates bank-to-bank width for a given angle of the line crossing through a specified point is riddled with local minima. Currently, a remedial approach is taken to mitigating this: it first finds the minimum width on a grid of 10 angles between 0 and pi (inclusive) (or 100 if the minimum is not unique at first), and then optimizes the width function around the minimum found on the grid. This slows down the algorithm noticeably, but not It's still possible, although likely very rare, for the global minimum to be missed. An improvement might involve choosing angles that do not intersect with the neighbouring cross section.

Another improvement to consider is to ensure cross sections go between left bank and right bank. Since points are being sampled along the centerline, this should be less of an issue, but there's still a chance where a cross section will be identified for a "bay" in the channel.

Examples

bl <- sf::st_sfc(demo_bankline, crs = 3005)
cross <- xt_generate_sxc(bl, n = 100)
plot(bl); plot(cross, add = TRUE, col = "blue")

# Inherits spatial properties of the bankline polygon, such as CRS:
sf::st_crs(cross)
#> Coordinate Reference System: NA