spsample-methods | R Documentation |
Methods for sampling in compact strata.
samples the centroids of each stratum.
stratified simple random sampling with n
samples per stratum.
if type = "composite"
, stratified simple random sampling of n
composites.
spatial infill sampling
stratify
for stratification, spsample
for other types of spatial sampling, and estimate
for inference.
# Note: the example below requires the 'sf'-package.
if (require(sf)) {
# read a vector representation of the `Farmsum' field
shpFarmsum <- as(st_read(
dsn = system.file("maps", package = "spcosa"),
layer = "farmsum"), "Spatial")
# stratify `Farmsum' into 50 strata
# NB: increase argument 'nTry' to get better results
set.seed(314)
myStratification <- stratify(shpFarmsum, nStrata = 50, nTry = 1)
# sample two sampling units per stratum
mySamplingPattern <- spsample(myStratification, n = 2)
# plot the resulting sampling pattern on
# top of the stratification
plot(myStratification, mySamplingPattern)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.