# \donttest{
library(blockCV)
# import presence-absence species data
points <- read.csv(system.file("extdata/", "species.csv", package = "blockCV"))
# make an sf object from data.frame
pa_data <- sf::st_as_sf(points, coords = c("x", "y"), crs = 7845)
# load raster data
path <- system.file("extdata/au/", package = "blockCV")
files <- list.files(path, full.names = TRUE)
covars <- terra::rast(files)
# spatial clustering
set.seed(6)
sc <- cv_cluster(x = pa_data,
column = "occ", # optional; name of the column with response
k = 5)
# environmental clustering
set.seed(6)
ec <- cv_cluster(r = covars, # if provided will be used for environmental clustering
x = pa_data,
column = "occ", # optional; name of the column with response
k = 5,
scale = TRUE)
# }
Run the code above in your browser using DataLab