Skip to contents

Compare sample representation within sraster strata

Usage

calculate_representation(sraster, existing, drop = NULL, plot = FALSE)

Arguments

sraster

spatRaster. Stratification raster.

existing

sf 'POINT'. Existing plot network.

drop

Numeric. Numeric value between 0-1 representing the sraster frequency (srasterFreq) below which strata will be dropped from comparison (e.g.. This parameter can be useful for when comparing stratum where percent coverage of strata may be ~ 0 percent and should be dropped. This could occur when mapping multiple stratifications.

plot

Logical. Plot frequency of strata coverage and sampling coverage for sraster and existing. Will return a list if TRUE.

Value

Returns a tibble where:

  • strata - sraster strata ID.

  • srasterFreq - sraster coverage frequency.

  • sampleFreq - Sampling frequency within sraster strata.

  • diffFreq - Difference between srasterFreq & sampleFreq. Positive values indicate over representation.

  • nSamp - Number of samples within each strata in existing.

  • need - srasterFreq * sum(nSamp). Total theoretical number of required samples to be representative of strata coverage. This values is rounded. It is important for the user to consider diffFreq. A small difference - e.g. 1 in sampleFreq vs. srasterFreq frequency could make the algorithm allocate or remove samples that could likely be ignored.

Details

Calculate how sraster strata are represented in existing samples

Author

Tristan R.H. Goodbody, Martin Queinnec

Examples

### --- generate example stratification ---###

#--- load ALS metrics from sgsR internal data ---#
r <- system.file("extdata", "mraster.tif", package = "sgsR")

#--- read ALS metrics using the terra package ---#
mraster <- terra::rast(r)

#--- perform stratification ---#
sraster <- strat_kmeans(
  mraster = mraster$zq90,
  nStrata = 6
)
#> K-means being performed on 1 layers with 6 centers.

### --- create existing sample network ---###

#--- simple random sampling ---#
existing <- sample_srs(
  raster = mraster$zq90,
  nSamp = 100
)

#--- calculate representation ---#

calculate_representation(
  sraster = sraster,
  existing = existing
)
#> # A tibble: 6 × 6
#>   strata srasterFreq sampleFreq diffFreq nSamp  need
#>    <int>       <dbl>      <dbl>    <dbl> <int> <dbl>
#> 1      1        0.24       0.32   0.08      32    -8
#> 2      2        0.09       0.06  -0.03       6     3
#> 3      3        0.09       0.15   0.06      15    -6
#> 4      4        0.27       0.23  -0.04      23     4
#> 5      5        0.12       0.11  -0.0100    11     1
#> 6      6        0.18       0.13  -0.05      13     5