Sample points along a linestring
Source:R/sample-points-along-linestring.R
sample_points_along_linestring.Rd
This function samples points at regular intervals along a linestring object.
Examples
library(sf)
# Create a linestrings
linestrings <- c(
create_linestring(0, 1, 2, 1),
create_linestring(1, 1.3, 1, 0, 2, 0.5)
)
# Sample points along the linestrings
sampled_points <- sample_points_along_linestring(linestrings, 0.5)
# Plot the sampled points
plot(linestrings)
plot(sampled_points, add = TRUE, pch = 16, col = c("#E69F00", "#56B4E9"))