0

Hi I am trying to run ENMeval on occurrence data and some rasters to determine settings for MaxEnt modelling. Whenever I try to run some of my code containing the raster layers, ie:

#resample layer
Elevation_resample <- resample(Elevation, FC, method = "bilinear")
Error in if (getOption("scipen") <= min(digits)) { : 
  missing value where TRUE/FALSE neededtype here
#reclassify layer
FC_rc <- reclassify(FC, matrix(c(NA, 0), ncol = 2))
Error in if (getOption("scipen") <= min(digits)) { : 
  missing value where TRUE/FALSE needed
#reclassify layer
Elevation_rc <- reclassify(Elevation, cbind(NA, 0))
Error in if (getOption("scipen") <= min(digits)) { : 
  missing value where TRUE/FALSE needed
#look for NA values in the raster
na_cells <- is.na(Elevation)
Error in h(simpleError(msg, call)) : 
  error in evaluating the argument 'filename' in selecting a method for function 'writeStart': missing value where TRUE/FALSE needed

I get the same error code coming up (this also comes up when I run ENMevaluate.

Any help with how I can get around this would be massively appreciated. I assumed it was something to do with having NA values but when I try to replace them with zero values that also gives the same message (see above)?

I have tried to turn the NA values in my raster datasets to 0 values but that does not seem to work. I have tried to restart and look for any packages I might be missing but also have no luck. At the moment I am stuck on the code above.

  • Maybe `scipen` is not set. Try setting it (e.g. `options(scipen = 99)`) at the console and try again. – Andrew Gustar Aug 12 '23 at 15:23
  • I'm inferring `raster::resample` or `terra::resample`, where is `reclassify` from? – r2evans Aug 12 '23 at 16:09
  • It seems possible but (to me) unlikely to be an issue with `scipen`, mostly because I think packages and functions tend to leave it alone. My guess is that whatever mechanism is being used to determine the local-variable `digits` is finding a corner case, either due to broken input or flawed process or something else. alex_allenby, I suggest it's likely to be a _bug_ with whichever package you're using, in which case providing a reproducible example to them might be simpler (where you can include `.rds` files for inputs, etc). – r2evans Aug 12 '23 at 16:33

1 Answers1

0

I installed R 4.3.1 recently on a new machine, and I encountered a similar error when running an old script of mine that did raster manipulation. But the error vanished when I rolled back to 4.2.3. I haven't tried with 4.3.0 yet. But my guess is that it's a bug in version 4.3.1.

KitS
  • 1