background: Obtain Background data

View source: R/background.R

backgroundR Documentation

Obtain Background data

Description

This function obtains background data given a set of predictors.

Usage

background(occ,
           pred = NULL,
           n = 10000,
           n_set = 1,
           proportion = NULL)

n_background(i)

background_data(i)

Arguments

occ

A occurrences_sdm or input_sdm object.

pred

A sdm_area object. If NULL and occ is a input_sdm, pred will be retrieved from occ.

n

numeric. Number of background records to be generated in each dataset created. If NULL then the function prevents imbalance by using the same number of presence records (n_records(occ)). If you want to address different sizes to each species, you must provide a named vector (as in n_records(occ)).

n_set

numeric. Number of datasets of background data to create.

proportion

numeric. A number between 0 and 1 representing a proportion of the area to be mapped as background. E.g.: if the whole area has 5,000 cells and proportion is 0.1, then n is set to 500. Standard is NULL. This argument overwrites n.

i

A input_sdm object.

Details

background is used in the SDM workflow to obtain background data, a step necessary for MaxEnt algorithm to run. This function helps avoid the use of pseudoabsence data in background algorithms and the use of background data in pseudoabsence algorithms, a very common mistake.

n_background returns the number of background records obtained per species.

background_data returns a list of species names. Each species name will have a lists with background data from class sf.

Value

A occurrences_sdm or input_sdm object with background data.

Author(s)

Luíz Fernando Esser (luizesser@gmail.com) https://luizfesser.wordpress.com

See Also

link{input_sdm} pseudoabsences occurrences_sdm

Examples

# Create sdm_area object:
sa <- sdm_area(parana, cell_size = 25000, crs = 6933)

# Include predictors:
sa <- add_predictors(sa, bioc) |> select_predictors(c("bio1", "bio4", "bio12"))

# Include scenarios:
sa <- add_scenarios(sa)

# Create occurrences:
oc <- occurrences_sdm(occ, crs = 6933) |> join_area(sa)

# Create input_sdm:
i <- input_sdm(oc, sa)

# Pseudoabsence generation:
i <- background(i, proportion = 1) # All available data is obtained as background data.


caretSDM documentation built on March 10, 2026, 5:08 p.m.