brshipley / megaSDM

Other
22 stars 3 forks source link

two small questions about running mega SDM #4

Closed PetiteTong closed 2 years ago

PetiteTong commented 2 years ago

Hi Ben,

At first I want to say thanks for your excellent work, megaSDM ! This is so convenient and helpful.

When I try to use it with my own occurrence data(tow columns, such as 102.00000 ,28.00000(unit °),as the function requirements), but my rasters are UTM reference frame. Maybe, should I change the rasters' system to make it the same as the point data? because I find that in thespecies.csv , the coordinates of the data are changed to UTM ,with unit m. I’m not sure whether this is ok or not?

Another one question is that

there is an error in the function MaxEntProj()


MaxEntProj(input = model_output,
           time_periods = time_periods,
           scenarios = scenarios,
           study_dir = study_dir,
           predict_dirs = predictdir,
           output = result_dir,
           aucval = 0.7,
           ncores = 2)

error as : the path of the maxentResults.csv is wrong, such as ,in example : D:/megaSDM/TestRun/models/Geomys_pinetis/maxentResults.csv but my error is : D:/megaSDM/TestRun/models/NA/maxentResults.csv

I could make sure that the name of the file and thespplist is right, and I checked theMaxEntProjfunction, but I still could not know how to solve it. and I also want to tell you that at the beginning, occurrences file was built by myself, I didn't have the SpeciesCounts file, if I should add one?

> MaxEntProj
function (input, time_periods, scenarios = NA, study_dir, predict_dirs, 
    output, ThreshMethod = "Maximum.test.sensitivity.plus.specificity", 
    aucval = NA, ncores = 1) 
{
    if (!dir.exists(output)) {
        dir.create(output)
    }
    studylayers <- list.files(study_dir, pattern = ".bil$", 
        full.names = TRUE)
    projstudy <- rep(NA, len = length(studylayers))
    extstudy <- rep(NA, len = length(studylayers))
    for (i in 1:length(studylayers)) {
        projstudy[i] <- as.character(raster::crs(raster::raster(studylayers[[i]])))
        extstudy[i] <- as.character(raster::extent(raster::raster(studylayers[[i]])))
    }
    if (length(unique(projstudy)) > 1) {
        stop("Not all of the study area environmental rasters are in the same projection")
    }
    else if (length(unique(extstudy)) > 1) {
        stop("Not all of the study area environmental rasters have the same extent")
    }
    studystack <- raster::stack(studylayers)
    if (is.na(raster::crs(studystack))) {
        stop("study area raster crs = NA: Ensure all raster layers have a defined coordinate projection")
    }
    else {
        desiredCRS <- raster::crs(studystack)
    }
    ListSpp <- list.dirs(input, full.names = FALSE, recursive = FALSE)
    ListSpp <- ListSpp[grep("_", ListSpp)]
    if (length(which(complete.cases(aucval))) > 0) {
        print(paste0("    Removing species with Test AUC Values < AUC threshold from subsequent analyses"))
        AUCRetain <- c()
        if (length(aucval) == 1) {
            aucval <- rep(aucval, length(ListSpp))
        }
        for (i in 1:length(ListSpp)) {
            results <- utils::read.csv(paste0(input, "/", 
                ListSpp[i], "/maxentResults.csv"))
            auc <- results$Test.AUC
            if (!is.na(aucval[i])) {
                aucAbove <- which(auc > aucval[i])
            }
            else {
                aucAbove <- 1:length(auc)
            }
            if (length(aucAbove) > 0) {
                AUCRetain <- c(AUCRetain, i)
            }
            else {
                message(paste0("Removing: ", ListSpp[i]))
            }
        }
        ListSpp <- ListSpp[c(AUCRetain)]
    }
    else {
        ListSpp <- ListSpp
        results <- utils::read.csv(paste0(input, "/", ListSpp[1], 
            "/maxentResults.csv"))
    }
    if (nrow(results) > 1) {
        nrep <- nrow(results) - 1
    }
    else {
        nrep <- 1
    }
    if (length(ListSpp) == 0) {
        stop(paste0("No species have AUC values higher than ", 
            aucval))
    }
    if (length(ListSpp) < ncores) {
        ncores <- length(ListSpp)
    }
    ListSpp <- matrix(data = ListSpp, ncol = ncores)
    currentYear <- time_periods[1]
    numYear <- length(time_periods)
    if (!is.na(scenarios)[1]) {
        numScenario <- length(scenarios)
    }
    else {
        numScenario <- 0
    }
    nproj <- 1 + (numScenario * (numYear - 1))
    if (!grepl(".logistic.threshold", ThreshMethod)) {
        ThreshMethod <- paste0(ThreshMethod, ".logistic.threshold")
    }
    threshold <- function(path, rasters, replicates, Scenario, 
        time) {
        rasters <- matrix(rasters, nrow = replicates)
        rasterNames <- c()
        ensemble.stack <- c()
        curmodel <- file.path(input, path)
        aucvalSpecies <- aucval[which(ListSpp == path)]
        results <- utils::read.csv(paste0(curmodel, "/maxentResults.csv"))
        for (j in 1:replicates) {
            if (!is.na(as.numeric(ThreshMethod))) {
                thresh <- as.numeric(ThreshMethod)
            }
            else {
                thresh <- results[j, ThreshMethod]
            }
            if (is.null(thresh)) {
                stop("The threshold for creating binary maps is not found in 'maxentResults.csv'. Revise in config")
            }
            if (!is.na(aucvalSpecies)) {
                tryCatch({
                  auc <- results$Test.AUC[j]
                  if (auc >= aucvalSpecies) {
                    temp <- raster::raster(rasters[j])
                    temp[temp >= thresh] <- 1
                    temp[temp < thresh] <- 0
                    rasterNames <- c(rasterNames, raster::filename(temp))
                    ensemble.stack <- raster::stack(c(ensemble.stack, 
                      temp))
                  }
                }, error = function(err) {
                  print(paste("MY_ERROR: ", path, " ", 
                    err, " j= ", j, " Scenario= ", 
                    Scenario, " time= ", time))
                })
            }
            else {
                temp <- raster::raster(rasters[j])
                temp[temp >= thresh] <- 1
                temp[temp < thresh] <- 0
                rasterNames <- c(rasterNames, raster::filename(temp))
                ensemble.stack <- raster::stack(c(ensemble.stack, 
                  temp))
            }
        }
        if (length(ensemble.stack) > 0) {
            ensemble.calc <- (raster::mean(ensemble.stack))
            rasterNames <- c(rasterNames, raster::filename(ensemble.calc))
            ensemble.calc[ensemble.calc >= 0.5] <- 1
            ensemble.calc[ensemble.calc < 0.5] <- 0
            raster::crs(ensemble.calc) <- desiredCRS
            if (!dir.exists(file.path(output, path, "map_pdfs"))) {
                dir.create(file.path(output, path, "map_pdfs"))
            }
            if (time == currentYear) {
                raster::crs(ensemble.calc) <- desiredCRS
                raster::writeRaster(ensemble.calc, filename = file.path(output, 
                  path, paste0(time, "_binary.bil")), overwrite = TRUE, 
                  format = "EHdr")
                grDevices::pdf(file = file.path(output, path, 
                  "map_pdfs", paste0(time, "_binary.pdf")))
                raster::plot(ensemble.calc, main = paste0(path, 
                  "_", time, "_binary"))
                grDevices::dev.off()
            }
            else {
                if (!dir.exists(file.path(output, path, Scenario))) {
                  dir.create(file.path(output, path, Scenario))
                }
                raster::crs(ensemble.calc) <- desiredCRS
                raster::writeRaster(ensemble.calc, filename = file.path(output, 
                  path, Scenario, paste0(time, "_", Scenario, 
                    "_binary.bil")), overwrite = TRUE, 
                  format = "EHdr")
                grDevices::pdf(file = file.path(output, path, 
                  "map_pdfs", paste0(time, "_", Scenario, 
                    "_binary.pdf")))
                raster::plot(ensemble.calc, main = paste0(path, 
                  "_", time, "_", Scenario, "_binary"))
                grDevices::dev.off()
            }
            return(ensemble.calc)
        }
        else {
            message(paste0("No replicates of ", path, " had a test AUC value above ", 
                aucval))
        }
        rm(temp, ensemble.stack)
        gc()
    }
    medianensemble <- function(path, rasters, replicates, Scenario, 
        decade) {
        rasters <- matrix(rasters, nrow = replicates)
        message("starting median ensemble")
        curmodel <- paste0(input, "/", path)
        ensemble.stack <- c()
        results <- utils::read.csv(paste0(curmodel, "/maxentResults.csv"))
        aucvalSpecies <- aucval[which(ListSpp == path)]
        for (j in 1:replicates) {
            if (!is.na(aucvalSpecies)) {
                tryCatch({
                  auc <- results$Test.AUC[j]
                  if (auc >= aucvalSpecies) {
                    temp <- raster::raster(rasters[j])
                    ensemble.stack <- raster::stack(c(ensemble.stack, 
                      temp))
                  }
                }, error = function(err) {
                  print(paste("MY_ERROR: ", path, " ", 
                    err, "j=", j, " Scenario= ", 
                    Scenario, " Decade= ", decade))
                })
            }
            else {
                temp <- raster::raster(rasters[j])
                ensemble.stack <- raster::stack(c(ensemble.stack, 
                  temp))
            }
        }
        if (raster::nlayers(ensemble.stack) > 1) {
            ensemble.calc <- raster::calc(ensemble.stack, stats::median, 
                na.rm = TRUE)
        }
        else {
            ensemble.calc <- ensemble.stack
        }
        if (decade == currentYear) {
            raster::crs(ensemble.calc) <- desiredCRS
            raster::writeRaster(ensemble.calc, filename = file.path(output, 
                path, paste0(decade, "_ensembled.bil")), 
                overwrite = TRUE, format = "EHdr")
            grDevices::pdf(file = file.path(output, path, "map_pdfs", 
                paste0(decade, "_ensembled.pdf")))
            raster::plot(ensemble.calc, main = paste0(path, "_", 
                decade))
            grDevices::dev.off()
        }
        else {
            raster::crs(ensemble.calc) <- desiredCRS
            raster::writeRaster(ensemble.calc, filename = file.path(output, 
                path, Scenario, paste0(decade, "_", Scenario, 
                  "_ensembled.bil")), overwrite = TRUE, 
                format = "EHdr")
            grDevices::pdf(file = file.path(output, path, "map_pdfs", 
                paste0(decade, "_", Scenario, "_ensembled.pdf")))
            raster::plot(ensemble.calc, main = paste0(path, "_", 
                decade, "_", Scenario))
            grDevices::dev.off()
        }
        rm(ensemble.stack)
        gc()
        return(ensemble.calc)
    }
    getSize <- function(raster) {
        return(raster::freq(raster, digits = 0, value = 1, useNA = "no", 
            progress = ""))
    }
    t1nott2 <- function(t1, t2) {
        tnew <- t1
        tnew[tnew == 1] <- 2
        Combined <- tnew + t2
        Combined[Combined != 2] <- 0
        Combined[Combined == 2] <- 1
        return(Combined)
    }
    overlap <- function(t1, t2) {
        Combined <- t1 + t2
        Combined[Combined != 2] <- 0
        Combined[Combined == 2] <- 1
        return(Combined)
    }
    getCentroid <- function(CentRaster) {
        points <- raster::rasterToPoints(CentRaster, fun = function(x) {
            x == 1
        }, spatial = FALSE)
        Clat <- mean(points[, 2], na.rm = TRUE)
        Clong <- mean(points[, 1], na.rm = TRUE)
        return(c(Clong, Clat))
    }
    getStats <- function(cur, j, decade, binary, stats, modern.size, 
        modern.binary) {
        stats$Projection[j] <- cur
        stats$NumberCells[j] <- getSize(binary)
        stats$CellChange[j] <- getSize(binary) - modern.size
        t1nott2_raster <- t1nott2(modern.binary, binary)
        t2nott1_raster <- t1nott2(binary, modern.binary)
        stats$T1notT2[j] <- getSize(t1nott2_raster)
        stats$T2notT1[j] <- getSize(t2nott1_raster)
        overlap_raster <- overlap(modern.binary, binary)
        stats$Overlap[j] <- getSize(overlap_raster)
        binary.centroid <- getCentroid(binary)
        stats$CentroidX[j] <- binary.centroid[1]
        stats$CentroidY[j] <- binary.centroid[2]
        return(stats)
    }
    run <- function(CurSpp) {
        spp.name <- CurSpp
        if (!dir.exists(file.path(output, spp.name))) {
            dir.create(file.path(output, spp.name))
        }
        stats <- as.data.frame(cbind(Projection = rep(0, times = nproj), 
            NumberCells = rep(0, times = nproj), CellChange = rep(0, 
                times = nproj), T1notT2 = rep(0, times = nproj), 
            T2notT1 = rep(0, nproj), Overlap = rep(0, times = nproj), 
            CentroidX = rep(0, times = nproj), CentroidY = rep(0, 
                times = nproj)))
        dir.create(file.path(output, spp.name, "projections"))
        dir.create(file.path(output, spp.name, "projections", 
            time_periods[1]))
        for (g in 1:nrep) {
            if (nrep == 1) {
                LambdaFile <- file.path(input, spp.name, paste0(spp.name, 
                  ".lambdas"))
                nrep_new <- 1
            }
            else {
                LambdaFile <- file.path(input, spp.name, paste0(spp.name, 
                  "_", g - 1, ".lambdas"))
                if (!file.exists(LambdaFile)) {
                  message(paste0("Model replicate ", g, 
                    " of species ", spp.name, " not found!"))
                  message(paste0("nrep may be greater than number of unique occurrences."))
                  message(paste0("Using fewer replicates for this species."))
                  nrep_new <- g - 1
                  (break)()
                }
                else {
                  nrep_new <- g
                }
            }
            system(paste0("java -mx900m -cp ", file.path(input, 
                "maxent.jar"), " density.Project ", 
                file.path(LambdaFile), " ", file.path(study_dir), 
                " ", file.path(output, spp.name, "projections", 
                  time_periods[1], paste0("RUN_", g - 1)), 
                " noaskoverwrite nowarnings -a"))
        }
        modern.rasters <- c()
        r <- list.files(path = file.path(output, spp.name, "projections", 
            time_periods[1]), pattern = paste0(".asc$"), 
            full.names = TRUE)
        for (k in 1:length(r)) {
            if (!grepl("clamping", r[k])) {
                modern.rasters <- c(modern.rasters, r[k])
            }
        }
        modern.rasters <- gtools::mixedsort(modern.rasters)
        modern.binary <- threshold(spp.name, modern.rasters, 
            nrep_new, "", currentYear)
        gc()
        if (length(modern.binary) > 0) {
            modern.median <- medianensemble(spp.name, modern.rasters, 
                nrep_new, "", currentYear)
            gc()
            statsrow <- 1
            stats$Projection[statsrow] <- currentYear
            modern.size <- getSize(modern.binary)
            stats$NumberCells[statsrow] <- modern.size
            modern.centroid <- getCentroid(modern.binary)
            stats$CentroidX[statsrow] <- modern.centroid[1]
            stats$CentroidY[statsrow] <- modern.centroid[2]
            if (numScenario > 0) {
                for (ScenIndex in 1:numScenario) {
                  dir.create(file.path(output, spp.name, "projections", 
                    scenarios[ScenIndex]))
                  for (YearIndex in 2:numYear) {
                    dir.create(file.path(output, spp.name, "projections", 
                      scenarios[ScenIndex], time_periods[YearIndex]))
                  }
                }
                for (ScenIndex in 1:numScenario) {
                  focusScen <- scenarios[ScenIndex]
                  for (YearIndex in 2:numYear) {
                    statsrow <- statsrow + 1
                    focusDate <- time_periods[YearIndex]
                    rasterLocation <- predict_dirs[[ScenIndex]][YearIndex - 
                      1]
                    for (g in 1:nrep_new) {
                      if (nrep == 1) {
                        LambdaFile <- file.path(input, spp.name, 
                          paste0(spp.name, ".lambdas"))
                      }
                      else {
                        LambdaFile <- file.path(input, spp.name, 
                          paste0(spp.name, "_", g - 1, 
                            ".lambdas"))
                      }
                      system(paste0("java -mx900m -cp ", 
                        file.path(input, "maxent.jar"), 
                        " density.Project ", LambdaFile, 
                        " ", rasterLocation, " ", 
                        output, "/", spp.name, "/projections/", 
                        focusScen, "/", focusDate, "/RUN_", 
                        g - 1, " noaskoverwrite nowarnings -a"))
                    }
                    cur.rasters <- list.files(path = file.path(output, 
                      spp.name, "projections", focusScen, 
                      focusDate), pattern = paste0("\\.asc$"), 
                      full.names = TRUE)
                    cur.proj <- c()
                    for (k in 1:length(cur.rasters)) {
                      if (!grepl("clamping", cur.rasters[k])) {
                        cur.proj <- c(cur.proj, cur.rasters[k])
                      }
                    }
                    length(cur.proj)
                    cur.binary <- threshold(spp.name, cur.proj, 
                      nrep_new, focusScen, focusDate)
                    gc()
                    cur.median <- medianensemble(spp.name, cur.proj, 
                      nrep_new, focusScen, focusDate)
                    gc()
                    stats <- getStats(paste0(focusScen, "_", 
                      focusDate), statsrow, focusDate, cur.binary, 
                      stats, modern.size, modern.binary)
                    gc()
                  }
                }
            }
            utils::write.csv(stats, file = file.path(output, 
                spp.name, "Results.csv"))
        }
        else {
            message(paste0("Removing ", spp.name, " from further analysis"))
        }
    }
    if (ncores == 1) {
        ListSpp <- as.vector(ListSpp)
        out <- sapply(ListSpp, function(x) run(x))
    }
    else {
        clus <- parallel::makeCluster(ncores, setup_timeout = 0.5)
        parallel::clusterExport(clus, varlist = c("run", 
            "threshold", "medianensemble", "getSize", 
            "t1nott2", "overlap", "getCentroid", 
            "getStats", "nrep", "currentYear", 
            "numYear", "numScenario", "nproj", 
            "input", "time_periods", "scenarios", 
            "predict_dirs", "study_dir", "ThreshMethod", 
            "aucval", "output", "ncores", "ListSpp", 
            "desiredCRS"), envir = environment())
        parallel::clusterEvalQ(clus, library(gtools))
        parallel::clusterEvalQ(clus, library(raster))
        for (i in 1:nrow(ListSpp)) {
            out <- parallel::parLapply(clus, ListSpp[i, ], function(x) run(x))
            gc()
        }
        parallel::stopCluster(clus)
    }
}
<bytecode: 0x000002018c891940>
<environment: namespace:megaSDM>

and the I find it is

brshipley commented 2 years ago

Hello! Thank you so much for your interest in this package! For your first question, using a raster in UTM coordinates should be OK for the modelling. The package automatically reprojects the occurrence points if they are in a different coordinate system than the environemntal rasters. I tried it out with the sample data, and it worked well, so no need to reproject the environmental rasters!

For the second issue (the error in the MaxentProj function), I was able to replicate it and fixed the issue. The function originally only worked if the entire scientific name of the species was used for the "spplist" argument (for example, "Canis_lupus" instead of "CL"). I removed that requirement and successfully tested it out so it should not be an issue anymore. If you redownload the package, the updated function should work with your data. Thanks again, and if you have any other questions or issues, please let me know!

-Ben Shipley

PetiteTong commented 2 years ago

Thanks Ben! You are so quickly to solve it! and now I will try again and add a categorical variables, do I need to add envs_stack$soil <- raster::as.factor(envs_stack$soil) to tell the program? I am not sure, I will try it. If there is some problems I will tell you~

Best wishes

Petite Tong

brshipley commented 2 years ago

Hi! I'm sorry that you've continued having issues with it!

I think I've had this problem before: An error says that maxent cannot work with rectangular pixels (different x and y sizes), but the rasters do not appear to have any different x and y values. It has something to do with some very minor differences in resolution. For example, the "raster" package usually rounds the displayed resolution values to about 5 decimal places, but the difference between the x and the y values might be in the 10th decimal place.

I've been working on trying to fix this issue (it is Issue #2 on Github), but I haven't quite figured it out yet. However, I have two ways to work around the problem:

  1. use a different resolution for the environmental data (for your data, I would suggest 30) This would be the "resolution" argument in the TrainStudyEnv function
  2. reproject the environmental rasters to an equal area projection (for example, "+proj=eqc +datum=WGS84 +units=m") This would be the "desiredCRS" argument in the TrainStudyEnv function

Then, if you have any future environmental layers, running PredictEnv to make sure all of the environmental rasters are in the same resolution and projection. Then, running every else as normal.

Let me know if you try these two options and you still get errors, and thank you so much for your patience! Ben Shipley

On Fri, Apr 15, 2022 at 3:44 AM PetiteTong @.***> wrote:

Hi, Ben

I tried to do this for study area and other scenarios:

BIO1=raster('.../bio1.bil')

BIO1c=raster('.../bio1.bil')

BIO2c=raster('.../bio2.bil')

BIO3c=raster('.../bio3.bil')

BIO4c=raster('.../bio4.bil')

BIO5c=raster('.../bio5.bil')

BIO6c=raster('.../bio6.bil')

biosc=stack(BIO1c,BIO2c,BIO3c,BIO4c,BIO5c,BIO6c)

names(biosc)=c("bio1","bio2","bio3","bio4","bio5","bio6")

n=nlayers(biosc)

for (i in 1:n) {

projectRaster(biosc[[i]],BIO1,

            filename=paste('.../',names(biosc[[i]]), sep=''),

            format = 'EHdr',overwrite=TRUE)

}

but no use for my problem.

Petite Tong

— Reply to this email directly, view it on GitHub https://github.com/brshipley/megaSDM/issues/4#issuecomment-1099935276, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANDTQKCTUHKA3LLQS4V42XTVFEM4NANCNFSM5TM4WTNQ . You are receiving this because you commented.Message ID: @.***>

PetiteTong commented 2 years ago

Hi,Ben

I want to say thank you very much for your help, It now works well!

I believe you can make it better.

I meet an error in the next step,like this:

> # The time maps will be written out to the directory supplied in "result_dir"
> result_dir <- "Results"
> createTimeMaps(result_dir = result_dir,
+                time_periods = time_periods,
+                scenarios = scenarios,
+                dispersal = FALSE,
+                ncores = 2)
Error in createTimeMaps(result_dir = result_dir, time_periods = time_periods,  : 
  No projected models found in 'result_dir': Ensure that 'result_dir' provides a path to the proper location
> result_dir
[1] "Results"
> additionalStats(result_dir = result_dir,
+                 time_periods = time_periods,
+                 scenarios = scenarios,
+                 dispersal = FALSE,
+                 ncores = 2)
Error in additionalStats(result_dir = result_dir, time_periods = time_periods,  : 
  No projected models found in 'result_dir': Ensure that 'result_dir' provides a path to the proper location 

I'm not sure if it is related to the warning:

> MaxEntProj(input = model_output,
+            time_periods = time_periods,
+            scenarios = scenarios,
+            study_dir = study_dir,
+            predict_dirs = predictdir,
+            output = result_dir,
+            aucval = 0.7,
+            ncores = 1)
[1] "    Removing species with Test AUC Values < AUC threshold from subsequent analyses"
starting median ensemble
starting median ensemble
starting median ensemble
starting median ensemble
starting median ensemble
starting median ensemble
starting median ensemble
starting median ensemble
starting median ensemble
starting median ensemble
There were 40 warnings (use warnings() to see them)
> warnings()
警告信息:
1: In threshold(spp.name, modern.rasters, nrep_new, "", currentYear) :
  强制改变过程中产生了NA
...
40: In threshold(spp.name, cur.proj, nrep_new, focusScen,  ... :
  强制改变过程中产生了NA

Or should I use the whole name of the species? Iwill try again.

Thanks a lot for your patience~

Petite Tong


YES!

It is because of the names of the species,"GGZ" "LLZ"are not ok. Just like the first problem. I have resolved it in my file. You can change it in the package when you have time.

Thanks, hope you all well.

brshipley commented 2 years ago

Hi,

I'm so glad that you figured it out! Thank you so much for your patience and finding that error in my code! I just fixed it on GitHub.

-Benjamin Shipley

On Sun, Apr 17, 2022 at 7:21 AM PetiteTong @.***> wrote:

Hi,Ben

I want to say thank you very much for your help, It now works well!

I believe you can make it better.

I meet an error in the next step,like this:

The time maps will be written out to the directory supplied in "result_dir"

result_dir <- "Results"

createTimeMaps(result_dir = result_dir,

  • time_periods = time_periods,

  • scenarios = scenarios,

  • dispersal = FALSE,

  • ncores = 2)

Error in createTimeMaps(result_dir = result_dir, time_periods = time_periods, :

No projected models found in 'result_dir': Ensure that 'result_dir' provides a path to the proper location

result_dir

[1] "Results"

additionalStats(result_dir = result_dir,

  • time_periods = time_periods,

  • scenarios = scenarios,

  • dispersal = FALSE,

  • ncores = 2)

Error in additionalStats(result_dir = result_dir, time_periods = time_periods, :

No projected models found in 'result_dir': Ensure that 'result_dir' provides a path to the proper location

I'm not sure if it is related to the warning:

MaxEntProj(input = model_output,

  • time_periods = time_periods,

  • scenarios = scenarios,

  • study_dir = study_dir,

  • predict_dirs = predictdir,

  • output = result_dir,

  • aucval = 0.7,

  • ncores = 1)

[1] " Removing species with Test AUC Values < AUC threshold from subsequent analyses"

starting median ensemble

starting median ensemble

starting median ensemble

starting median ensemble

starting median ensemble

starting median ensemble

starting median ensemble

starting median ensemble

starting median ensemble

starting median ensemble

There were 40 warnings (use warnings() to see them)

warnings()

警告信息:

1: In threshold(spp.name, modern.rasters, nrep_new, "", currentYear) :

强制改变过程中产生了NA

...

40: In threshold(spp.name, cur.proj, nrep_new, focusScen, ... : 强制改变过程中产生了NA

Or should I use the whole name of the species? Iwill try again.

Thanks a lot for your patience~

Petite Tong


YES!

It is because of the names of the species,"GGZ" "LLZ"are not ok. Just like the first problem. I have resolved it in my file. You can change it in the package when you have time.

Thanks, hope you all well.

— Reply to this email directly, view it on GitHub https://github.com/brshipley/megaSDM/issues/4#issuecomment-1100856195, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANDTQKBRHHBSZ6WPNBQY4DLVFPX5HANCNFSM5TM4WTNQ . You are receiving this because you commented.Message ID: @.***>