Assume a segment string of class SpatialLines length len . This line starts in the upper left corner.
library(sp) x <- structure(list(x = c(-7.23437435517476, 6.35937810318614, -5.86718660792582, 7.96094089282062), y = c(7.08139459814975, 6.8633712983227, -7.61337581019376, -6.2180266913006)), .Names = c("x", "y")) xline <- SpatialLines(list(Lines(Line(x), ID = 1))) #len <- LineLength(as.matrix(data.frame(x))) len <- LineLength(as.matrix(data.frame(coordinates(xline)))) plot(0,0, xlim = c(-10, 10), ylim = c(-10, 10), type = "n") lines(xline)

I would like to find a point on this line that is at a distance findme from the beginning of the line. For example, if I were looking for a point with 10 units along the line from the beginning, I would get a point near the node between the first and second segments. Your contribution to a more reliable solution is most welcome.
I tried to find it using spsample (see below), but this method is (also) unreliable and does not work for points in the second half of the line.
# very approximate method, not very suitable findme <- 11 # 11, 12 and 13 give same result segs <- 1/(findme/xline.length) xsam <- spsample(x = xline, n = segs, type = "regular", offset = 0) points(xsam)
source share