This function splits a line into multiple lines at specified points.
+Arguments
+ + +- line +
A
LINESTRING
object.
+
+
+- split_points +
A
sfc
object containing points to split the line.
+
+
+- tolerance +
A numeric value representing the maximum distance +between the line and the split points. If the distance between a +split point and the line is greater than this value, the point +will not be used to split the line.
+
+
Examples
+library(sf)
+
+# Create a line
+line <- create_linestring(0, 0, 5, 5)
+
+# Create a set of points
+split_points <- st_sfc(
+ st_point(c(0.0, 0.0)),
+ st_point(c(3.5, 3.5)),
+ st_point(c(1.0, 1.0))
+)
+
+# Plot the line and split points
+plot(line, lwd = 2)
+plot(split_points, add = TRUE, pch = 3, lwd = 2)
+
+
+# Split the line at the specified points
+split_lines <- split_line(line, split_points)
+
+# Plot the split lines
+plot(split_lines, lwd = 2, col = c("#E69F00", "#56B4E9", "#009E73"))
+
+