# NOT RUN {
# load package data
library(sf)
awt <- raster::brick(system.file("extdata", "awt.grd", package = "blockCV"))
# import presence-absence species data
PA <- read.csv(system.file("extdata", "PA.csv", package = "blockCV"))
# make a sf object from data.frame
pa_data <- sf::st_as_sf(PA, coords = c("x", "y"), crs = raster::crs(awt))
# spatial blocking by specified range and random assignment
sb1 <- spatialBlock(speciesData = pa_data,
species = "Species",
theRange = 70000,
k = 5,
selection = "random",
iteration = 100,
numLimit = NULL,
biomod2Format = TRUE,
xOffset = 0.3, # shift the blocks horizontally
yOffset = 0)
# spatial blocking by row/column and systematic fold assignment
sb2 <- spatialBlock(speciesData = pa_data,
species = "Species",
rasterLayer = awt,
rows = 5,
cols = 8,
k = 5,
selection = "systematic",
biomod2Format = TRUE)
# }
Run the code above in your browser using DataLab