[R-sig-Geo] Generating Random Transects of Same Length

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Thu Feb 12 20:42:40 CET 2009


2009/2/12 Marcelino de la Cruz <marcelino.delacruz at upm.es>:
>
> As an spatstat aficionado, I would use the following code:

 Very very nice, but:

> #compute a circle around each point
> cosadisc<- apply(cosaxy,1, function(x) disc(r=ltransect, x))

 generates 128 points on a circle around each point. There's a teeny
tiny chance that none of those points will be in your polygon :)  What
you've done is a rejection method where you generate 128 and throw 127
away!

 I can see the following ways of doing this:

 A:  1. generate first point from CSR on the polygon
      2. generate second point at distance D from first point
      3. goto *2* until second point is in polygon.

 B: 1. generate first point from CSR on the polygon
     2. generate second point at distance D from the first point
     3. goto *1* until second point is in polygon

 C: buffer zone method

your code essentially does A, where the first points are CSR but the
second points arent (I think), and B will have neither first points
nor second points as CSR since it avoids the edges.

the buffer zone method produces CSR in the inner zone for the first
points and non-CSR for the second points.

all depends on what the original questioner wanted - if just a bunch
of segments of length D roughly scattered around inside the polygon
then wham! your lovely spatstat code is exactly that!

Barry



More information about the R-sig-Geo mailing list