无法使用 {sdmData} 编译数据集 - 错误

问题描述

我正在使用 {sdm} 包进行入侵物种的物种分布建模。 {vifcor} 成功完成,排除了具有高相关性的变量(栅格)。 我无法将我的栅格(生物气候变量,海拔,ndvi),发生数据编译到 {sdmData} 对象中。以下是我的代码错误

library(sdm)
d <- sdmData(formula=species~.,train=lant,predictors=brt_all)

错误

d <- sdmData(formula=species~.,predictors=brt_all)
Error in (function (classes,fdef,mtable)  : 
unable to find an inherited method for function ‘sdmData’ for signature ‘"formula","sf","missing","RasterStack"’

解决方法

{sdm} 包中仍然不支持 sf 对象。使用以下作品

lant <- as(lant,'Spatial')

将 lant 转换为 SpatialPointsDataFrame。