This function breaks up a LINESTRING geometries into smaller pieces.
See also
Other lines:
angle_diff()
,
geo_toptail()
,
is_linepoint()
,
line2df()
,
line2points()
,
line_bearing()
,
line_midpoint()
,
line_segment()
,
line_segment1()
,
line_via()
,
mats2line()
,
n_segments()
,
n_vertices()
,
onewaygeo()
,
points2line()
,
toptail_buff()
Examples
library(sf)
z <- zones_sf$geometry
l <- routes_fast_sf$geometry[2]
l_split <- line_breakup(l, z)
l
#> Geometry set for 1 feature
#> Geometry type: LINESTRING
#> Dimension: XY
#> Bounding box: xmin: -1.550964 ymin: 53.82387 xmax: -1.516748 ymax: 53.83041
#> Geodetic CRS: WGS 84
#> LINESTRING (-1.516748 53.82868, -1.517513 53.82...
l_split
#> Geometry set for 3 features
#> Geometry type: LINESTRING
#> Dimension: XY
#> Bounding box: xmin: -1.550964 ymin: 53.82387 xmax: -1.516748 ymax: 53.83041
#> Geodetic CRS: WGS 84
#> LINESTRING (-1.516748 53.82868, -1.517513 53.82...
#> LINESTRING (-1.526629 53.82927, -1.526957 53.82...
#> LINESTRING (-1.545996 53.82493, -1.546004 53.82...
sf::st_length(l)
#> 2982.689 [m]
sum(sf::st_length(l_split))
#> 2982.689 [m]
plot(z)
plot(l, add = TRUE, lwd = 9, col = "grey")
plot(l_split, add = TRUE, col = 1:length(l_split))