Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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

Author(s)

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")

spatialEco

Spatial Analysis and Modelling Utilities

v1.3-6
GPL-3
Authors
Jeffrey S. Evans [aut, cre], Melanie A. Murphy [ctb], Karthik Ram [ctb]
Initial release
2021-03-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.