Creates an equal sample of n for each polygon in an sp Polygon class object

sample.poly(x, n = 10, type = "random", ...)

Arguments

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

Value

sp SpatialPointsDataFrame object

Author

Jeffrey S. Evans <jeffrey_evans@tnc.org>

Examples

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)
plot(s, pch = 20, add = TRUE)
box()
title("Random sample (n=5) for each polygon")