prepare_swd: Prepare data for SWD maxent calibration processes

View source: R/prepare_swd.R

prepare_swdR Documentation

Prepare data for SWD maxent calibration processes

Description

prepare_swd helps to create csv files containing occurrence records (all, train, and test records) and background coordinates, together with values of predictor variables, that later can be used to run model calibration in Maxent using the SWD format.

Usage

prepare_swd(occ, species, longitude, latitude, data.split.method = "random",
            train.proportion = 0.5, raster.layers, sample.size = 10000,
            var.sets = NULL, min.number = 2, save = FALSE, name.occ,
            back.folder, set.seed = 1)

Arguments

occ

data.frame containing occurrence records of the species of interest. Mandatory columns are: species, longitude, and latitude. Other columns will be ignored.

species

(character) name of column containing species name.

longitude

(character) name of column containing longitude values.

latitude

(character) name of column containing latitude values.

data.split.method

(character) name of the method to split training and testing records. Default and only option for now = "random".

train.proportion

(numeric) proportion of records to be used for training models. Default = 0.5

raster.layers

RasterStack of predictor variables masked to the area where the model will be calibrated.

sample.size

(numeric) number of points to represent the background for the model. Default = 10000

var.sets

(character or list) if character the only option is "all_comb", which will prepare the background to obtain all potential combinations of variables considering the ones in raster.layers. The minimum number of variables per set is defied by min.number. If list, a list of character vectors with the names of the variables per each set. Names of variables in sets must match names of layers in raster.layers. The default (NULL) produces only one set of variables for the background.

min.number

(numeric) minimum number of variables per set when option "all_comb" is used in var.sets. Default = 2.

save

(logical) whether or not to write csv files containing all, train, and test occurrences, as well as the background. All files will contain additional columns with the values of the variables for each coordinate. Default = FALSE.

name.occ

(character) name to be used for files with occurrence records. Only one name is needed, a sufix will be added to represent all (_join), _train, and _test records (e.g., "occurrences").

back.folder

name for the csv file containing background coordinates (e.g., "background").

set.seed

seed to be used when sampling background and splitting records. Default = 1

Examples

# data
data("sp_joint", package = "kuenm")
occ <- data.frame(Species = "A_americanum", sp_joint)

mvars <- raster::stack(list.files(system.file("extdata", package = "kuenm"),
                                  pattern = "Mbio_", full.names = TRUE))

# preparing swd data one set of variables
prep <- prepare_swd(occ, species = "Species", longitude = "Longitude",
                    latitude = "Latitude", raster.layers = mvars,
                    sample.size = 5000)

# various sets of variables
preps <- prepare_swd(occ, species = "Species", longitude = "Longitude",
                     latitude = "Latitude", raster.layers = mvars,
                     var.sets = "all_comb", min.number = 3,
                     sample.size = 5000)

manubio13/ku.enm documentation built on Jan. 5, 2024, 5:55 a.m.