Description Usage Arguments Details Value Author(s) Examples

View source: R/CM.calculateCenterline.r

Calculate the centerline of the channel polygon in 5 steps:

creating Voronoi polygons of the bank points, convert to paths (line segments with two ends) and remove duplicates

filtering for path segments that lie within the banks

filtering for path segments that are dead ends (have less than 2 connected ends)

sorting of the centerline segments to generate centerline

smooth the centerline

1 | ```
CM.calculateCenterline(cmgo.obj, set = NULL)
``` |

`cmgo.obj` |
the global object of type list containing data and parameters created with |

`set` |
an optional argument for processing a specific data set, if |

`CM.calculateCenterline()`

calculates the centerline of the channel polygon (Fig. 7).

*Figure 6: A visualization of the calculation of the centerline a) the channel polygon, b) the Voronoi polygons,
c) extraction of the centerline segments, d) smoothing of the centerline path.*

The function requires as input the channel polygon (Fig. 6a) which must be stored within the global data object
previously generated with `CM.generatePolygon()`

.
The algorithm then creates Voronoi polygons around the bank points (Fig. 6b).
Voronoi polygons around points denote the areas within which all points are closest to that point. The polygons
are disassembled to single line segments. In Fig. 6b you can already notice a centerline evolving from the segments in
the middle of the channel polygon. To get only these segments a filtering (Fig. 7) is applied to the Voronoi segments.

*Figure 7: the filtering of the Voronoi segments: a) in blue all Voronoi segments, b) in red all segments fully within
the channel polygon, c) in green all segments without dead ends.*

To retrieve only the segments that represent the centerline all segments that do not lie entirely within the channel banks are removed (Fig. 7b). In a second step dead ends are removed (Fig. 7c). Dead ends are segments that branch from the centerline but are not part of it.

These centerline segments will be
chained to one consistent line and get smoothed (Fig. 7d). The degree of smoothing can be adjusted
through the parameter `centerline.smoothing.width`

(defaults to the same value as
`bank.interpolate.max.dist`

). This centerline represents the reference of the river, for which
length, local width and slope are calculated next. Note, that the length of the centerline has decreased
by the smoothing in d). It is important to understand, that the length of a river is not a well-defined measure.
The length of a river depends on the resolution of the bank points. Similar to
the coast line paradox, the length depends on the
scale of the observations. Technically, a bended river is a fractal, which
means theoretically, the length diverges to infinity at an infinitely high resolution of the bank points.
However, practically there is an appropriate choice of a minimum feature size. Every user has to determine this
scale individually and should be aware of this choice. The decrease in length due to smoothing
is saved as value in the global data object under `cmgo.obj$data[[set]]$cl$length.factor`

. A value of 0.95 means
that the length of the smoothed centerline is 95% the length of the original centerline paths.

returns the global data object extended by the centerline data `$cl`

for the respective data set(s)

Antonius Golly

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ```
# get demo data
# (find instructions on how to use own data in the documentation of CM.ini())
cmgo.obj = CM.ini("demo")
# generate the polygon from the bank points
cmgo.obj = CM.generatePolygon(cmgo.obj)
# calculate the centerline from the polygon
cmgo.obj = CM.calculateCenterline(cmgo.obj)
# check results
plot.par = CM.plotPlanView(cmgo.obj)
# change degree of smoothing, re-calculate centerline and plot
cmgo.obj$par$centerline.smoothing.width = 12
cmgo.obj = CM.calculateCenterline(cmgo.obj)
plot.par = CM.plotPlanView(cmgo.obj)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.