R/river_voronoi.R
river_voronoi.Rd
The function creates Voronoi diagram for each segment in a directed
connected river network (sf LINESTRING
), where the Voronoi
polygons join together at network segment intersections. The function
requires package lwgeom
and will not work without it.
river_voronoi(river, aoi, riverID = "riverID", verbose = FALSE)
river | An 'sf' linestring feature representing a river network. |
---|---|
aoi | An area of interest. 'sf' polygon object. Optional. |
riverID | A character string which specifies the name of the column in
|
verbose | Whether or not print progress indicators. |
Returns an 'sf' polygon object, with a column "ID" corresponding to the river segment IDs.
Creating the segment Voronoi diagram is done in the following steps:
Move starting and ending nodes forward or backwards (respectively) for a small amount to ensure there are no identically placed nodes.
Compute a Voronoi diagram from point cloud of river segment nodes.
Union the individual polygons using river segment ID.
Clip the polygons to the area of interest.
Process erroneous polygons, if any.
The accuracy of the final segment Voronoi diagram is depending on the
density of nodes in the river network. Consider densifying geometry e.g.
with sf::st_segmentize()
function for higher accuracy.