library(spatstat) # Swedish pine data data(swedishpines) # Plot the point process plot(swedishpines) # Plot the point process with a density estimate plot(density.ppp(swedishpines)) points(swedishpines) # You can specify your own sigma plot(density.ppp(swedishpines, sigma=5)) points(swedishpines) # An adaptive density estimate plot(adaptive.density(swedishpines)) points(swedishpines) # Repeat the randomization and average plot(adaptive.density(swedishpines, nrep=50)) points(swedishpines) # Test of CSR based on quadrats, t = quadrat.test(swedishpines, nx=3, ny=3) print(t) plot(t, col='red') points(swedishpines) # Some data that is not CSR p = rSSI(0.05, 200) print(quadrat.test(p, 3)) plot(quadrat.test(p, 3), col='red') points(p) # Some data that is not CSR p = rThomas(20, 0.1, 10) print(quadrat.test(p, 3)) plot(quadrat.test(p, 3), col='red') points(p) # Point process of location of tropical trees data(bei) plot(bei) # Some measure of the slope of the terrain Z = bei.extra$grad plot(Z) points(bei) # Do a similar test of CSR but using different regions b = quantile(Z, probs = (0:4)/4) Zcut <- cut(Z, breaks = b, labels = 1:4) V <- tess(image = Zcut) plot(V) points(bei) print(quadrat.test(bei, tess = V))