# 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)
# plot the resulting stratification
plot(myStratification)
}
Run the code above in your browser using DataLab