[R-sig-Geo] Distribute points along lines

Agustin Lobo alobolistas at gmail.com
Fri Jul 3 19:01:29 CEST 2009


Thanks,

I'm actually doing:

plot(fl1)
points(spsample(fl1[4,],5,offset=0.001,type="regular"))

but why offset=0 does not work?
 > points(spsample(fl1[4,],5,offset=0.0,type="regular"))
Error in validObject(.Object) :
invalid class "SpatialPoints" object: bbox should never contain NA values

Also, which are the units for offset? I'm actually trying to set real
field sampling sites, so this matters. The best would be being able to 
set the first point in the
line and then the nb of points for random sites (as it is currently done)
and the length interval for regular sampling.

By now I can adjust the nb. of points for the interval I want if the 
length of
the line is known, but how can I calculate the length of the lines? 
calcLength
requires another type of spatial object.

Agus



Roger Bivand wrote:
> 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
>>>
>>>
>>
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: alobolistas.vcf
Type: text/x-vcard
Size: 251 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20090703/48fbe622/attachment.vcf>


More information about the R-sig-Geo mailing list