Learn R Programming

tidysdm (version 1.0.0)

blockcv2rsample: Convert an object created with blockCV to an rsample object

Description

This function converts 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)

Value

an rsample object

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.

Examples

Run this code
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)

Run the code above in your browser using DataLab