Skip to content
Prev 6004 / 29559 Next

Distribute points along lines

On Sun, 5 Jul 2009, Agustin Lobo wrote:

            
The problem was that sp:::sample.Line() was not handling a zero-length 
line segment (two identical consecutive coordinates in a Line object) 
properly, provoking an error when offset was set to 0.

I've committed changes to sourceforge:

cvs -z3 \
-d:pserver:anonymous at r-spatial.cvs.sourceforge.net:/cvsroot/r-spatial \
co -P sp

(all one line), then

R CMD INSTALL sp

to try out. I have also reversed the meaning of offset for lines, 0 is now 
the start coordinate of the Line object. If possible, could you please 
check out the revision, install it from source, and try it - it resolves 
the problem for your case as far as I can tell.
There are LineLength(), LinesLength(), and SpatialLinesLengths() 
functions in sp, more used internally than exposed, but should be OK. I've 
converted LineLength() to use C code, so they can now also measure lengths 
in km even if the data are in geographical coordinates (assuming WGS84), 
as in spDistsN1().

Roger