Open Wycology opened 5 months ago
Seems the implementation of terra functions and objects was the issue. If I wrap the x and h arguments to raster::stack and raster, the niche plot works fine as shown.
niche(x = raster::stack(preds), h = raster(p1), c('precipitation','temperature'))
The niche function does not plot x and y values properly. They appear to overlap near the 0,0 coordinate.
library(sdm)
species <- vect(system.file("external/species.shp", package = "sdm"))
preds <- rast(list.files(path = system.file("external", package = "sdm"), pattern = 'asc$', full.names = TRUE))
names(preds)
d <- sdmData(formula = Occurrence~., train = species, predictors = preds)
m <- sdm(Occurrence~., data = d, methods = c('rf', 'glm', 'brt'))
p1 <- ensemble(m, newdata = preds, setting = list(method = 'weighted', stat = 'AUC'))
niche(x = preds, h = p1, c('precipitation', 'temperature'))