2009/2/12 Marcelino de la Cruz <marcelino.delac...@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 _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo