Raster R Error: Error in { : task 1 failed - "0 (non-NA) cases"

Viewed 71

I'm trying to conduct a landscape genetic analysis through the R Package ResistanceGA on some environmental rasters. However, I keep running into the error Error in { : task 5 failed - "0 (non-NA) cases" when my rasters are being passed through the algorithm. I've had no issues to date with any of the other datasets that I've used, however, this dataset was sourced externally. This leads me to believe that it is something to do with the raster itself, and not the package. All rasters are in .asc format and have been converted from GeoTIFFs.

Data can be found here.

The full code used:

# Load Package
library(ResistanceGA) 
library(rgdal)
library(corpcor)
library(pryr)

## Create Directory for Examples ##
if("ResistanceGA_Examples"%in%dir("D:/ResistanceGA/Data/Model_Outputs/100m")==FALSE)
  dir.create(file.path("D:/ResistanceGA/Data/Model_Outputs/", "100m"))

## Create Directory Object for .asc Files and results
write.dir <- "D:/ResistanceGA/Data/Model_Outputs/FINAL"

## Set working directory ##
setwd("D:/ResistanceGA/Data/Model_Ouputs/100m")

## Set ASC Directory ##
asc.dir <- "D:/ResistanceGA/Data/FINAL/100m/ASC"

## Sample locations
samples <- read.table("D:/ResistanceGA/EGK_SampleLoc.txt", sep="")
sp.dat <- SpatialPoints(samples[,c(1,2)], proj4string = CRS("+proj=longlat +datum=WGS84"))
sp.dat.reproj <- spTransform(sp.dat, CRS("+proj=utm +zone=56 +south"))

## Input Genetic Matrix ##
gen_dist <- read.table('D:/ResistanceGA/EGK_Fst.txt', sep="", header = FALSE)

## Bring in Geochemistry Rasters ##
carbon <- raster('carbon.asc')
phos <-raster('phosphorus.asc')
nit <-raster('nitrogen.asc')

## Create the Raster Stack ##
r.stack <- stack(carbon, phos, nit)

## Change Projection Of Datasets ##
crs(sp.dat.reproj)<- CRS("+proj=utm +zone=56 +south +datum=WGS84")
crs(r.stack)<- CRS("+proj=utm +zone=56 +south +datum=WGS84")

## Genetic Distance Inputs ##
gdist.inputs <- gdist.prep(length(sp.dat.reproj),
                           samples = sp.dat.reproj,
                           response = lower(as.matrix(gen_dist)),
                           method = 'commuteDistance')

GA.inputs <- GA.prep(ASCII.dir = r.stack,
                     Results.dir = write.dir,
                     parallel = 14)

SS_RESULTS.gdist <- SS_optim(gdist.inputs = gdist.inputs,
                             GA.inputs = GA.inputs)

Error arises when the following is run:

SS_RESULTS.gdist <- SS_optim(gdist.inputs = gdist.inputs,
                             GA.inputs = GA.inputs)

and outputs:

Error in { : task 5 failed - "0 (non-NA) cases"

When it should output iterative metrics like:

GA | iter = 1 | Mean = -57442.214 | Best =    155.842
GA | iter = 2 | Mean = -56714.224 | Best =    157.142
GA | iter = 3 | Mean = -28712.441 | Best =    159.342
GA | iter = 4 | Mean = -34414.224 | Best =    159.842
0 Answers
Related