danlwarren / ENMTools

ENMTools R Package
104 stars 30 forks source link

Checking breadth and overlap from ASCII files produced by maxent #239

Closed kmechan closed 1 year ago

kmechan commented 1 year ago

Hello all!

I've produced SDMs from GIS and run them through maxent, and I now want to use ENMTools to look at niche breadth and niche overlap between species. My supervisor has mentioned that I should just be able to use the ACII files maxent produces from my models, but when I try to look at breadth or overlap, it comes up with an error:

r issue

I'm relatively new to using R, so I imagine the issue is likely me. Nevertheless, my supervisor and I need help figuring out what exactly the problem is.

Would you happen to have any suggestions on how to fix this, or know where exactly I've gone wrong?

Many thanks

rdinnager commented 1 year ago

Hi @kmechan, thanks for the bug report. ENMTools latest version has switched from the raster package to the terra package for dealing with spatial data. Normally we check for this and give an informative error message but it looks like those two functions were forgotten. We will work on a fix, but in the mean-time you just need to load your raster files in using terra instead. This should work (let us know if it doesn't):

library(terra)
library(ENMTools)
cheetah <- terra::rast("Acinonyx_jubatus_avg.asc")
raster.breadth(cheetah)

And do the same for the loading the lion data. Just for future reference, please paste your code and any error messages as text into the issue, rather than using just a screenshot. This just makes it easier for us to test your code because we can copy and paste it instead of transcribing from an image.

@danlwarren It looks like we forgot to add any checks or coercion attempts to raster.breadth() and raster.overlap(). I can add this if you are too busy, but probably not until next week.

kmechan commented 1 year ago

Hi @kmechan, thanks for the bug report. ENMTools latest version has switched from the raster package to the terra package for dealing with spatial data. Normally we check for this and give an informative error message but it looks like those two functions were forgotten. We will work on a fix, but in the mean-time you just need to load your raster files in using terra instead. This should work (let us know if it doesn't):

library(terra)
library(ENMTools)
cheetah <- terra::rast("Acinonyx_jubatus_avg.asc")
raster.breadth(cheetah)

And do the same for the loading the lion data. Just for future reference, please paste your code and any error messages as text into the issue, rather than using just a screenshot. This just makes it easier for us to test your code because we can copy and paste it instead of transcribing from an image.

@danlwarren It looks like we forgot to add any checks or coercion attempts to raster.breadth() and raster.overlap(). I can add this if you are too busy, but probably not until next week.

This has worked perfectly. Thank you so much!

Apologies for the screenshot. I'll be sure to paste the code next time.

danlwarren commented 1 year ago

No worries!