st_linesubstring | R Documentation |
get substring from linestring
st_linesubstring(x, from, to, tolerance, ...)
x |
object of class |
from |
relative distance from origin (in [0,1]) |
to |
relative distance from origin (in [0,1]) |
tolerance |
tolerance parameter, when to snap to line node node |
... |
ignored |
object of class sfc
library(sf)
lines = st_sfc(st_linestring(rbind(c(0,0), c(1,2), c(2,0))), crs = 4326)
spl = st_linesubstring(lines, 0.2, 0.8) # should warn
plot(st_geometry(lines), col = 'red', lwd = 3)
plot(spl, col = 'black', lwd = 3, add = TRUE)
st_linesubstring(lines, 0.49999, 0.8) # three points
st_linesubstring(lines, 0.49999, 0.8, 0.001) # two points: snap start to second node
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.