# Acquire environmental variables
files <- list.files(path = file.path(system.file(package = "dismo"), "ex"),
pattern = "grd",
full.names = TRUE)
predictors <- terra::rast(files)
# Prepare presence and background locations
p_coords <- virtualSp$presence
bg_coords <- virtualSp$background
# Create SWD object
data <- prepareSWD(species = "Virtual species",
p = p_coords,
a = bg_coords,
env = predictors,
categorical = "biome")
if (FALSE) {
# The following commands save the output in the working directory
# Save the SWD object as a single csv file
swd2csv(data,
file_name = "train_data.csv")
# Save the SWD object in two separate csv files
swd2csv(data,
file_name = c("presence.csv", "absence.csv"))}
Run the code above in your browser using DataLab