# NOT RUN {
library(quickPlot)
set.seed(1234)
Ras <- randomPolygons(numTypes = 5)
if (interactive()) {
clearPlot()
Plot(Ras, cols = c("yellow", "dark green", "blue", "dark red"))
}
library(raster)
# more complex patterning, with a range of patch sizes
a <- randomPolygons(numTypes = 400, raster(extent(0, 50, 0, 50), res = 1, vals = 0))
a[a<320] <- 0
a[a>=320] <- 1
suppressWarnings(clumped <- clump(a)) # warning sometimes occurs, but not important
aHist <- hist(table(getValues(clumped)), plot = FALSE)
if (interactive()) {
clearPlot()
Plot(a)
Plot(aHist)
}
library(sp)
b <- SpatialPoints(cbind(-110, 59));
a <- randomPolygon(b, 1e4);
plot(a);
points(b, pch=19)
# }
Run the code above in your browser using DataLab