spatialEco (version 1.3-2)

sample.poly: Sample Polygons

Description

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

Usage

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

Examples

Run this code
# NOT RUN {
 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")	   

# }

Run the code above in your browser using DataLab