
Last chance! 50% off unlimited learning
Sale ends in
Remove all but one location per raster cell. The function removes NAs and if more than one location falls within the same raster cell it selects randomly one.
thinData(coords, env)
data.frame or matrix with the coordinates.
a data frame with the thinned locations.
coords and env must have the same coordinate reference system.
# NOT RUN {
# Acquire environmental variables
files <- list.files(path = file.path(system.file(package = "dismo"), "ex"),
pattern = "grd", full.names = TRUE)
predictors <- raster::stack(files)
# Prepare background locations
bg_coords <- dismo::randomPoints(predictors, 9000)
nrow(bg_coords)
# Thin the locations
thinned_bg <- thinData(bg_coords, env = predictors)
nrow(thinned_bg)
# }
Run the code above in your browser using DataLab