Skip to contents

RandomSpatialSample: uniform random points in a polygon. HexagonalGridSample: hexagonal grid in a polygon as sp::spsample(type = "hexagonal"). AdaptiveClusterSample: Thompson's adaptive cluster sampling with modified Hansen-Hurwitz and Horvitz-Thompson estimators. QuadtreeGrid: adaptive-resolution quadtree cells. VoronoiDeclusteringWeights and CellDeclusteringWeights: declustering weights. SpatialThinning: randomised thinning to a minimum distance. MapQualityIndices: ME, MAE, MSE, RMSE, r2 and MEC. Identical to the Python arm morie.fn.spsampling.

Usage

RandomSpatialSample(n, polygon, seed = 1)

HexagonalGridSample(polygon, cellsize, offset = c(0.5, 0.5))

AdaptiveClusterSample(y, initial = NULL, threshold, n = NULL, seed = 1)

QuadtreeGrid(points, bbox, capacity = 4L, max_depth = 8L)

VoronoiDeclusteringWeights(points, bbox)

CellDeclusteringWeights(points, cell_size, origin = c(0, 0))

SpatialThinning(points, min_dist, reps = 10L, seed = 1)

MapQualityIndices(z, zhat, pi = NULL, N = NULL)

Arguments

n

Sample size.

polygon

Two-column matrix of polygon vertices.

seed

Philox seed.

cellsize

Hexagon spacing.

offset

Lattice offset (fractions of a cell).

y

Population grid (matrix).

initial

Two-column matrix of initial cells (0-based row, col), or NULL.

threshold

Condition value.

points

Two-column matrix of points.

bbox

Box (xmin, ymin, xmax, ymax).

capacity, max_depth

Quadtree leaf capacity and depth limit.

cell_size, origin

Declustering cell size and grid origin.

min_dist, reps

Thinning distance and passes.

z, zhat

Observations and predictions.

pi, N

Inclusion probabilities and population size.

Value

Matrix or list.

References

Thompson, S. K. (1990). Adaptive cluster sampling. JASA 85, 1050-1059.

Aiello-Lammens, M. E. et al. (2015). spThin: an R package for spatial thinning of species occurrence records. Ecography 38, 541-545.

Deutsch, C. V. (1989). DECLUS: a Fortran 77 program for determining optimum spatial declustering weights. Computers and Geosciences 15, 325-332.

Brus, D. J. (2022). Spatial Sampling with R. CRC Press.

Examples

sq <- rbind(c(0, 0), c(10, 0), c(10, 10), c(0, 10))
nrow(HexagonalGridSample(sq, 2))
#> [1] 23
CellDeclusteringWeights(rbind(c(0.1, 0.1), c(0.2, 0.2), c(1.5, 0.5)), 1)$weights
#> [1] 0.25 0.25 0.50
MapQualityIndices(c(1, 2, 3, 4), c(1.5, 1.5, 3.5, 3.5))$MEC
#> [1] 0.8