Skip to content
Prev 5030 / 29559 Next

Generating Random Transects of Same Length

2009/2/12 Marcelino de la Cruz <marcelino.delacruz at upm.es>:
Very very nice, but:
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