Does anybody know how to solve this problem?
I’m trying to build a species Distribution model using bioclimatic variables
sdm
package by Naimi, 2016
R version 4.4.1
ERROR:
model <- sdm(Species ~ ., data = sdm_data,
methods = c('glm', 'gam', 'gbm', 'rf', 'svm', 'mars'))
Error in x@presence : no applicable method for
@
applied to an object of class “NULL”
Part of code:
bioclim_files <- list.files(pattern = "*.tif$", full.names = TRUE)
Study_Area <- st_read("shp/3Province.shp")
DEM <- rast ("shp/DEM.tif")
DEM_crop <- crop (DEM, Study_Area)
DEM_mask <- mask (DEM_crop, Study_Area)
Bio <- rast(bioclim_files)
Bio <- crop (Bio, Study_Area)
Bio <- mask (Bio, Study_Area)
ext(Bio)
ext(DEM)
Bio_crop <- crop(Bio, ext(DEM))
Bio_resample <- resample(Bio_crop, DEM) #Bio1_2_4_8_15_18
occurance_data <- import("p_i.xlsx")
sdm_data <- sdmData(Species ~ . + coords(Lon + Lat),
train = occurance_data,
predictors = Bio_resample)
print(sdm_data)
summary(sdm_data)
model <- sdm(Species ~ ., data = sdm_data,
methods = c('glm', 'gam', 'gbm', 'rf', 'svm', 'mars'))
str(sdm_data)
I’ve tried capital letters like ‘Species’ or ‘species’, even added more occurrence data but none of them worked.
Simon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.