I think the below is a solution:
library(raster)
# create some lines
cds1 <- rbind(c(-180,-20), c(-140,55), c(10, 0), c(-140,-60))
cds2 <- rbind(c(-10,0), c(140,60), c(160,0), c(140,-55))
cds3 <- rbind(c(-125,0), c(0,60), c(40,5), c(15,-45))
lns <- SpatialLines(list(Lines(list(Line(cds1)), "1"),
Lines(list(Line(cds2)), "2"), Lines(list(Line(cds3)), "3") ))
# get coordinates
xy <- as.data.frame(lns, xy=TRUE)
# get midpoints
x <- xy$x[-1] + (xy$x[-nrow(xy)] - xy$x[-1]) / 2
y <- xy$y[-1] + (xy$y[-nrow(xy)] - xy$y[-1]) / 2
m <- cbind(x,y)
# remove mid-points between non-segments
i <- xy$cump[-1] == xy$cump[-nrow(xy)]
m <- m[i,]
plot(lns)
points(m)
On Thu, Oct 23, 2014 at 8:56 AM, Edzer Pebesma
<edzer.pebesma at uni-muenster.de> wrote:
sp::spsample also offers regular sampling of points on SpatialLines objects.
On 10/23/2014 05:21 PM, Mathieu Basille wrote:
Dear list members,
How to segment or split a spatial line in shorter equal segments, and
also,
how to get the mid point of ecah segment.
Best,
Manuel
--
Edzer Pebesma, Co-Editor-in-Chief Computers & Geosciences
Institute for Geoinformatics (ifgi), University of M?nster
Heisenbergstra?e 2, 48149 M?nster, Germany. Phone: +49 251
83 33081 http://ifgi.uni-muenster.de GPG key ID 0xAC227795