【问题标题】:Project MaxENT fitted model into geographic spaceProject MaxENT 将模型拟合到地理空间
【发布时间】:2020-02-03 05:25:45
【问题描述】:

回答了类似的问题here;但是,这个问题有点不同,我无法应用该解决方案。我已经使用 site-with-data 格式安装了 maxent。问题是我无法投影拟合模型。路径D:/maxentm1 的输出看起来不错。我怀疑这两个错误(如下)与 rJava 有关,但我不知道解决方案。请参阅下面的代码:

> m1 <- maxent(x = d, p = id, path = "D:/maxent", 
             args = c("-P", "noautofeature", "nolinear", "noquadratic", "nothreshold", 
                      "noproduct", "betamultiplier=1", "replicates=10", "crossvalidate"))

# here d is a dataframe containing 11213 rows and 20 predictor columns (with numeric values), id is a vector containing numeric values of 1 and 0 (representing species presence and absence)
Loading required namespace: rJava
> plot(m1, xlim=c(0,100))
Error in as.double(y) : 
  cannot coerce type 'S4' to vector of type 'double'

> ras <- raster("E:/bio12.tif") # raster to project the fitted model 'm1'

> pred.m1 <- raster::predict(m1, ras)
Error in .local(object, ...) : missing layers (or wrong names)

这是光栅文件的属性

> ras
class       : RasterLayer 
dimensions  : 4292, 4936, 21185312  (nrow, ncol, ncell)
resolution  : 0.008333333, 0.008333333  (x, y)
extent      : 112.8917, 154.025, -43.75833, -7.991667  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 
data source : E:/Predictors_grasshoppers/selected.predictors/bio12.tif 
names       : bio12 
values      : 79, 7625  (min, max)

更新:我尝试在 m1 中使用单引号,但问题仍然存在。

> m2 <- maxent(x = d, p = id, path = 'D:/PhD related/Historic climate data Australia/maxent2', 
             args = c('-P', 'noautofeature', 'nolinear', 'noquadratic', 'nothreshold', 
                      'noproduct', 'betamultiplier=1', 'replicates=10', 'crossvalidate'))

【问题讨论】:

  • path = "D:/maxent" 文件夹中有哪些文件?请出示。
  • 这些是maxent模型的常用输出文件(共92项:1个文件夹包含数字,其他只是文件)。以前我运行了类似的模型,没有问题,也生成了类似的文件。
  • 我的意思是你显示了maxent模型中使用的输入名称。
  • 谢谢。我再次更新我的问题。
  • 您的输入包含 20 个预测变量列,但在预测期间,您仅使用一个变量。您应该尝试在所有 20 个与输入名称相同的预测变量的栅格堆栈上进行预测。

标签: r rjava maxent


【解决方案1】:

根据@Bappa Das 的评论,我找到了解决方案。要将 maxent 拟合模型投影到地理空间中,应该使用包含在模型拟合过程中使用的变量的栅格堆栈(而不是单个栅格)。栅格堆栈中预测变量的顺序和名称应与拟合模型中的相同。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-09
    • 2020-11-20
    • 1970-01-01
    • 2017-02-26
    • 1970-01-01
    • 1970-01-01
    • 2020-04-16
    • 2014-12-11
    相关资源
    最近更新 更多