Skip to content

suggestion to imrpove: Generating Random Transects of Same Length (by marcelino de la cruz)

2 messages · gianni lavaredo, Marcelino de la Cruz

#
See below:
At 22:40 18/02/2010, gianni lavaredo wrote:
###########################
#### START HERE::
# you mean 100 transects i.e. one in each tile
npoints <- 100
s <- 1:npoints

#create the tiles object:
Ztiles <- tiles(Z)
# better, choose one random point within each tile:
srp2 <- lapply(Ztiles, function(x) rpoint(1,w=x)) 
#one rnadom point within each tile
lapply(srp2,plot, pch=20,cex = 0.8, add=T,col="blue")
srp.xy<-t(sapply(srp2, function(k) c(k$x,k$y)))
srp.disc <- lapply(srp2, function(x) disc(r=ltransect, c(x$x,x$y)))
# test if every circle point is inside the 
polygonal boundary of each tile
srp.disc.df <- NULL
for (i in 1:length(srp.disc)){
      srp.disc.df[[i]] <- inside.owin(srp.disc[[i]]$bdry[[1]]$x,
                                             srp.disc[[i]]$bdry[[1]]$y 
,w=Ztiles[[i]])

}
Hope this helps!

Marcelino
________________________________

Marcelino de la Cruz Rot

Departamento de  Biolog?a Vegetal
E.U.T.I. Agr?cola
Universidad Polit?cnica de Madrid
28040-Madrid
Tel.: 91 336 54 35
Fax: 91 336 56 56
marcelino.delacruz at upm.es
_________________________________