if (FALSE) {
#########
# Let's read raster dataset containing predictor variables for this study area:
file <- system.file("external/predictors.tif", package="sdm") # path to a raster object
r <- rast(file)
r # a SpatRaster object including 2 rasters (covariates)
plot(r)
#----
file <- system.file("external/po_spatial_points.shp", package="sdm") # path to a shapefile
po <- vect(file) # spatial points with presence-only records
head(po) # it contains data for one species (sp4) and the dataset has only presence records!
b1 <- background(r,n=20,method = 'gRandom') # you may specify the bias file (a raster object)
head(b1) # background records generated using gRandom
b2 <- background(r,n=20,method = 'eRandom')
head(b2) # background records generated using eRandom
b3 <- background(r,n=20,method = 'eDist',sp=po)
head(b3) # background records generated using eDist
b4 <- background(r,n=20,method = 'gDist')
head(b4) # background records generated using gDist
}
Run the code above in your browser using DataLab