Creates an equal sample of n for each polygon in an sp Polygon class object
sample.poly(x, n = 10, type = "random", ...)
x | sp class SpatialPolygons or SpatialPolygonsDataFrame object |
---|---|
n | Number of random samples |
type | Type of sample with options for: "random", "regular", "stratified", "nonaligned", "hexagonal", "clustered", "Fibonacci". See "spsample" for details. |
... | Additional arguments passed to spsample |
sp SpatialPointsDataFrame object
Jeffrey S. Evans <jeffrey_evans@tnc.org>
library(raster) library(sp) p <- raster(nrow=10, ncol=10) p[] <- runif(ncell(p)) * 10 p <- rasterToPolygons(p, fun=function(x){x > 9}) s <- sample.poly(p, n = 5, type = "random") plot(p)