View source: R/transLines2pix.r
transLines2pix | R Documentation |
Convert a simple feature geometry made of MULTILINESTRING and/or LINESTRING into a POINT geometry with points at regular distance between nodes
transLines2pix(spldf,mindist=100)
spldf |
A |
mindist |
the distance between two points (default to 100) |
This function can be used e.g to discretize track lines (roads, paths, transects, etc.) into series of regular points. Each point is the centre of one interval. Beware that if mindist is larger than the distance between nodes, the output file will keep the nodes. Furthermore, mindist might not be fully respected in some spatial configurations. In such cases to filter points using st_thintrack
complementarily is advised.
A sf object
with a POINT geometry type.
trans2pix
, st_thintrack
, mergeTrackObs
if (require(sf)) {
l1 = st_linestring(cbind(c(1,2,3),c(3,2,2)))
S1<-st_multilinestring(list(l1,cbind(l1[,1]+.05,l1[,2]+.05)))
S2<-st_linestring(cbind(c(1,2,3),c(1,1.5,1)))
sl<-st_sfc(list(S1,S2))
plot(sl, col = c("red", "blue"),reset=FALSE)
trpt<-transLines2pix(sl,mindist=0.1)
plot(st_geometry(trpt),add=TRUE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.