blockcv2rsample {tidysdm}R Documentation

Convert an object created with blockCV to an rsample object

Description

This function creates objects created with blockCV to rsample objects that can be used by tidysdm. BlockCV provides more sophisticated sampling options than the spatialsample library. For example, it is possible to stratify the sampling to ensure that presences and absences are evenly distributed among the folds (see the example below).

Usage

blockcv2rsample(x, data)

Arguments

x

a object created with a blockCV function

data

the sf object used to create x

Details

Note that currently only objects of type cv_spatial and cv_cluster are supported.

Value

an rsample object

Examples


library(blockCV)
points <- read.csv(system.file("extdata/", "species.csv", package = "blockCV"))
pa_data <- sf::st_as_sf(points, coords = c("x", "y"), crs = 7845)
sb1 <- cv_spatial(
  x = pa_data,
  column = "occ", # the response column to balance the folds
  k = 5, # number of folds
  size = 350000, # size of the blocks in metres
  selection = "random", # random blocks-to-fold
  iteration = 10
) # find evenly dispersed folds
sb1_rsample <- blockcv2rsample(sb1, pa_data)
class(sb1_rsample)
autoplot(sb1_rsample)


[Package tidysdm version 0.9.5 Index]