line_segment | R Documentation |
This function keeps the attributes.
Note: results differ when use_rsgeo
is TRUE
:
the {rsgeo}
implementation is faster and more reliably
keeps returned linestrings below a the segment_length
value.
line_segment(l, segment_length = NA, use_rsgeo = NULL, debug_mode = FALSE)
l |
A spatial lines object |
segment_length |
The approximate length of segments in the output (overides n_segments if set) |
use_rsgeo |
Should the |
debug_mode |
Should debug messages be printed? Default is FALSE. |
Other lines:
angle_diff()
,
geo_toptail()
,
is_linepoint()
,
line2df()
,
line2points()
,
line_bearing()
,
line_breakup()
,
line_midpoint()
,
line_segment1()
,
line_via()
,
mats2line()
,
n_segments()
,
n_vertices()
,
onewaygeo()
,
points2line()
,
toptail_buff()
library(sf)
l <- routes_fast_sf[2:4, ]
l_seg_multi <- line_segment(l, segment_length = 1000, use_rsgeo = FALSE)
plot(l_seg_multi, col = seq_along(l_seg_multi), lwd = 5)
round(st_length(l_seg_multi))
# Test rsgeo implementation:
# rsmulti = line_segment(l, segment_length = 1000, use_rsgeo = TRUE)
# plot(rsmulti, col = seq_along(l_seg_multi), lwd = 5)
# round(st_length(rsmulti))
# waldo::compare(l_seg_multi, rsmulti)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.