我最近在R (dismo-package)中与MaxEnt一起做了很多工作,但只使用交叉验证来验证我的鸟类栖息地模型(只有一个物种)。现在我想使用一个自创建的测试样例文件。我不得不手工选择这个点进行验证,并且不能使用随机测试点。
我的R-脚本是这样的:
library(raster)
library(dismo)
setwd("H:/MaxEnt")
memory.limit(size = 400000)
punkteVG <- read.csv("Validierung_FL_XY_2016.csv", header=T, sep=";", dec=",")
punkteTG <- read.csv("Training_FL_XY_2016.csv", header=T, sep=";", dec=",")
punkteVG$X <- as.numeric(punkteVG$X)
punkteVG$Y <- as.numeric(punkteVG$Y)
punkteTG$X <- as.numeric(punkteTG$X)
punkteTG$Y <- as.numeric(punkteTG$Y)
##### mask NA ######
mask <- raster("final_merge_8class+le_bb_mask.img")
dataframe_VG <- extract(mask, punkteVG)
dataframe_VG[dataframe_VG == 0] <- NA
dataframe_TG <- extract(mask, punkteTG)
dataframe_TG[dataframe_TG == 0] <- NA
punkteVG <- punkteVG*dataframe_VG
punkteTG <- punkteTG*dataframe_TG
#### add the raster dataset ####
habitat_all <- stack("blockstats_stack_8class+le+area_8bit.img")
#### MODEL FITTING #####
library(rJava)
system.file(package = "dismo")
options(java.parameters = "-Xmx1g" )
setwd("H:/MaxEnt/results_8class_LE_AREA")
### backgroundpoints ###
set.seed(0)
backgrVMmax <- randomPoints(habitat_all, 100000, tryf=30)
backgrVM <- randomPoints(habitat_all, 1000, tryf=30)
### Renner (2015) PPM modelfitting Maxent ###
maxentVMmax_Renner<-maxent(habitat_all,punkteTG,backgrVMmax, path=paste('H:/MaxEnt/Ergebnisse_8class_LE_AREA/maxVMmax_Renner',sep=""),
args=c("-P",
"noautofeature",
"nothreshold",
"noproduct",
"maximumbackground=400000",
"noaddsamplestobackground",
"noremoveduplicates",
"replicates=10",
"replicatetype=subsample",
"randomtestpoints=20",
"randomseed=true",
"testsamplesfile=H:/MaxEnt/Validierung_FL_XY_2016_swd_NA"))在"maxent()"-command之后,我遇到了多个错误。首先,我得到了一个错误,说明他需要超过0(这是默认的)“随机测试点”。所以我添加了“随机测试点= 20”(希望这不会阻止程序使用文件)。然后我得到了:
Error: Test samples need to be in SWD format when background data is in SWD format
Error in file(file, "rt") : cannot open the connection问题是,当我使用默认的交叉验证运行脚本时,如下所示:
maxentVMmax_Renner<-maxent(habitat_all,punkteTG,backgrVMmax, path=paste('H:/MaxEnt/Ergebnisse_8class_LE_AREA/maxVMmax_Renner',sep=""),
args=c("-P",
"noautofeature",
"nothreshold",
"noproduct",
"maximumbackground=400000",
"noaddsamplestobackground",
"noremoveduplicates",
"replicates=10"))...all工作得很好。
此外,我尝试了多种方法来获得我的csv-验证-数据以正确的格式。两行(标记X和Y),三行(标记物种,X和Y)和其他东西。我宁愿使用"punkteVG"-vector (这是用read.csv...but创建的验证数据),因为MaxEnt似乎想要他的文件。
我无法想象我的问题如此罕见。一定有人用过"testsamplesfile“这个论点。
发布于 2017-10-04 09:02:13
我发现问题出在哪里。因此,对其他人来说,这就是享受:
子示例文件的正确maxent-命令如下所示:
maxentVMmax_Renner<-maxent(habitat_all, punkteTG, backgrVMmax, path=paste('H:/MaxEnt',sep=""),
args=c("-P",
"noautofeature",
"nothreshold",
"noproduct",
"maximumbackground=400000",
"noaddsamplestobackground",
"noremoveduplicates",
"replicates=1",
"replicatetype=Subsample",
"testsamplesfile=H:/MaxEnt/swd.csv"))当然,不可能有多个副本,因为只有一个子样本。最重要的是,"swd.csv“子示例文件必须包括:
最后一点就是这里的问题。基本上,如果您不定义子样本文件中的物种-colum,MaxEnt将不知道如何分配数据。
https://stackoverflow.com/questions/45862924
复制相似问题