getSample {spbal}R Documentation

Extract a sample of a specified size from a master sample.

Description

A description of this useful function.

Usage

getSample(shapefile, n, randomStart = FALSE, strata = NULL, stratum = NULL)

Arguments

shapefile

A MULTIPOINT or POINT object from where to take the sample.

n

The number of sample points to return.

randomStart

Whether a spatially balanced sample will be randomly drawn from the frame or not. Default value is FALSE.

strata

to be added

stratum

The name of a column in the dataframe attached to shapefile that defines the strata of interest.

Value

A list containing the following variable:

Author(s)

Phil Davies.

Examples

# Draw a spatially balanced sample of n = 25 from a Halton Frame over Gates --

# Use the North Carolina shapefile supplied in the sf R package.
shp_file <- sf::st_read(system.file("shape/nc.shp", package="sf"))
shp_gates <- shp_file[shp_file$NAME == "Gates",]

# Vertically aligned master sample bounding box.
bb <- spbal::BoundingBox(shapefile = shp_gates)

set.seed(511)
result7 <- spbal::HaltonFrame(shapefile = shp_gates,
                              J = c(6, 4),
                              boundingbox = bb)
Frame <- result7$hf.pts.shp

# Get the first 25 sites from a B = (2^6) * (3^4) Halton Frame (62,208 grid
# points covering Gates).
n_samples <- 25
FrameSample <-getSample(shapefile = Frame,
                        n = n_samples)
FrameSample <- FrameSample$sample
FrameSample


[Package spbal version 1.0.0 Index]