# A random pattern:
set.seed(42)
xy1 <- data.frame(x=runif(400,0,20),y=runif(400,0,20))
dxy1 <- deldir(xy1)
ldxy1 <- lawSummary(dxy1)
tl1 <- tile.list(dxy1)
plot(0,0,type="n",xlim=c(-2,35),ylim=c(0,20),asp=1,xlab="x",ylab="y",bty="l")
plot(tl1,showpoints=FALSE,add=TRUE)
points(xy1[attr(ldxy1,"i1"),],pch=20,col="yellow")
points(xy1[attr(ldxy1,"i2"),],pch=20,col="blue")
points(xy1[attr(ldxy1,"i3"),],pch=20,col="green")
points(xy1[attr(ldxy1,"i.kept"),],pch=20,col="red")
legend("right",pch=20,col=c("yellow","blue","green","red"),
legend=c("layer 1","layer 2","layer 3","interior"))
# A highly structured pattern (example due to Kai Xu):
set.seed(115)
x <- c(rep(1:20,10),rep((1:20)+0.5,10))
y <- c(rep(1:10,each=20),rep((1:10)+0.5,each=20))*sqrt(3)
a <- runif(400,0,2*pi)
b <- runif(400,-1,1)
x <- x+0.1*cos(a)*b
y <- y+0.1*sin(a)*b
xy2 <- data.frame(x,y)
dxy2 <- deldir(xy2)
ldxy2 <- lawSummary(dxy2)
tl2 <- tile.list(dxy2)
plot(0,0,type="n",xlim=c(-2,35),ylim=c(0,20),asp=1,xlab="x",ylab="y",bty="l")
plot(tl2,showpoints=FALSE,add=TRUE)
points(xy2[attr(ldxy2,"i1"),],pch=20,col="yellow")
points(xy2[attr(ldxy2,"i2"),],pch=20,col="blue")
points(xy2[attr(ldxy2,"i3"),],pch=20,col="green")
points(xy2[attr(ldxy2,"i.kept"),],pch=20,col="red")
legend("right",pch=20,col=c("yellow","blue","green","red"),
legend=c("layer 1","layer 2","layer 3","interior"))
Run the code above in your browser using DataLab