Distribute points along lines
On Fri, 3 Jul 2009, Kamran Safi wrote:
Hi, I think you can use spsample() together with type=random and n=your sample size.
Exactly: library(sp) data(meuse.riv) SL <- SpatialLines(list(Lines(list(Line(meuse.riv[1:80,])), ID="1"))) plot(SL) pts <- spsample(SL, n=50, type="random") plot(pts, add=TRUE) Here we only have one Line object in the single Lines object, but the principle is the same. Roger
Kami Agustin Lobo wrote:
Hi! Is there any way to distribute a set of random or regularly-spaced points along a line imported from a shape file into a SpatialLinesDataFrame? I've been searching, but could not find it. Should I use coordinates() to get the vertex, then calculate the a&b parameters for each line and distribute the points? Or is it there something already done? Thanks, Agus Dr. Agustin Lobo Institut de Ciencies de la Terra "Jaume Almera" (CSIC) LLuis Sole Sabaris s/n 08028 Barcelona Spain Tel. 34 934095410 Fax. 34 934110012 email: Agustin.Lobo at ija.csic.es http://www.ija.csic.es/gt/obster
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no