sample_envbg: Generate random environmental background data

View source: R/sample_envbg.R

sample_envbgR Documentation

Generate random environmental background data

Description

Generate environmental background data is a function similar to sampleRandom function of the raster package but optimized for Ecological niche modeling.

Usage

sample_envbg(
  envlayers,
  nbg,
  nprop = NULL,
  coordinates = FALSE,
  cellIDs = FALSE,
  rseed = NULL,
  parallel = TRUE,
  ncores = 4
)

Arguments

envlayers

A raster stack or brick.

nbg

Number of points for the background data

nprop

Proportion of environmental data to be sampled. Default NULL

coordinates

Logical. If TRUE cell coordinates will be returned

cellIDs

Logical. If TRUE cell IDs will be returned

rseed

Random seed number. Default NULL

parallel

Run the process in parallel

ncores

Number of workers to run the parallel process.

Examples

## Not run: 
wcpath <- list.files(system.file("extdata/bios",
                                 package = "ntbox"),
                     pattern = ".tif$",
                     full.names = TRUE)

envlayers <- raster::stack(wcpath)
vals <- sample_envbg(envlayers,nbg = 3583)
# Using a proportion of data
vals <- sample_envbg(envlayers,nprop = 0.20)

## End(Not run)

luismurao/ntbox documentation built on May 9, 2024, 8:24 p.m.