Description Usage Arguments Examples
View source: R/clean_segments_by_length.R
Removes tiny (below 1e-4, by default) segments generated by calc_stream_voronoi_weights
that
take up unnecessary space in the PBJ file and unnecessary processing power in MF-USG.
Adds the tiny pieces back to another segment so lengths are not lost.
Takes advantage of the fact that if it's a tiny segment it almost certainly came from
a triangle corner, and triangle corners are completely in ONE node.
1 2 3 4 5 6 | clean_segments_by_length(
swdf,
min_seg_length = 1e-04,
forward_add = T,
verbose = T
)
|
swdf |
Output from |
min_seg_length |
Minimum allowed segment length (default: 1e-4) |
forward_add |
T/F Add to subsequent row in swdf (default: True). False adds to previous row. Regardless, opposite direction will be tried at start/end of swdf |
verbose |
T/F if information should be relayed through messages (default: True). |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #-- Read in shapefiles
str <- read_sf(system.file("extdata", "straight_river.shp", package = "pbjr"))
tri <- read_sf(system.file("extdata", "straight_triangles.shp", package = "pbjr"))
vor <- read_sf(system.file("extdata", "straight_voronoi.shp", package = "pbjr"))
#-- Explode polyline
str <- line_explode(str)
#-- Create SWDF
swdf <- calc_stream_voronoi_weights(stream = str, voronoi = vor, triangles = tri,
geometry = T, correct_seg_order = T)
#-- Clean up
swdf <- clean_segments_by_length(swdf)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.