Skip to contents

Balanced raster sampling using lcube and lpm2_kdtree methods

Usage

sample_balanced(
  mraster,
  nSamp,
  algorithm = "lpm2_kdtree",
  p = NULL,
  access = NULL,
  buff_inner = NULL,
  buff_outer = NULL,
  plot = FALSE,
  filename = NULL,
  overwrite = FALSE
)

Arguments

mraster

spatRaster. ALS metrics raster.

nSamp

Numeric. Number of desired samples.

algorithm

Character. One of lpm2_kdtree, lcube, lcubestratified.

p

Numeric. Vector with length equal to the number of cells in mraster representing the inclusion probability for each candidate sample. Default = nSamp / N, where N is the number of cells.

access

sf 'LINESTRING' or 'MULTILINESTRING'. Access network.

buff_inner

Numeric. Inner buffer boundary specifying distance from access where plots cannot be sampled.

buff_outer

Numeric. Outer buffer boundary specifying distance from access where plots can be sampled.

plot

Logical. Plots output strata raster and visualized strata with boundary dividers.

filename

Character. Path to write stratified raster to disc.

overwrite

Logical. Specify whether filename should be overwritten on disc.

Value

An sf object with nSamp samples.

References

Anton Grafstrom and Jonathan Lisic (2019). BalancedSampling: Balanced and Spatially Balanced Sampling. R package version 1.5.5. https://CRAN.R-project.org/package=BalancedSampling

Jonathan Lisic and Anton Grafstrom (2018). SamplingBigData: Sampling Methods for Big Data. R package version 1.0.0. https://CRAN.R-project.org/package=SamplingBigData

Grafström, A. Lisic, J (2018). BalancedSampling: Balanced and Spatially Balanced Sampling. R package version 1.5.4. http://www.antongrafstrom.se/balancedsampling

Author

Tristan R.H. Goodbody

Examples

#--- Load raster and existing plots---#
r <- system.file("extdata", "mraster.tif", package = "sgsR")
mr <- terra::rast(r)

a <- system.file("extdata", "access.shp", package = "sgsR")
ac <- sf::st_read(a)
#> Reading layer `access' from data source 
#>   `/home/runner/work/_temp/Library/sgsR/extdata/access.shp' 
#>   using driver `ESRI Shapefile'
#> Simple feature collection with 167 features and 2 fields
#> Geometry type: MULTILINESTRING
#> Dimension:     XY
#> Bounding box:  xmin: 431100 ymin: 5337700 xmax: 438560 ymax: 5343240
#> Projected CRS: UTM_Zone_17_Northern_Hemisphere

sample_balanced(
  mraster = mr,
  nSamp = 200
)
#> Simple feature collection with 200 features and 0 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: 431130 ymin: 5337710 xmax: 438530 ymax: 5343210
#> CRS:           +proj=utm +zone=17 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs
#> First 10 features:
#>                  geometry
#> 1  POINT (437330 5343210)
#> 2  POINT (431790 5343190)
#> 3  POINT (435110 5343190)
#> 4  POINT (438430 5343190)
#> 5  POINT (434650 5343130)
#> 6  POINT (438310 5343110)
#> 7  POINT (435850 5343090)
#> 8  POINT (435670 5343070)
#> 9  POINT (437850 5343070)
#> 10 POINT (437850 5343050)