Thursday, March 2, 2023

Big Changes in ENMTools 1.1.0!

ENMTools version 1.1.0 is now on the master branch on github.  We're working on getting ENMTools back on CRAN, but it has necessitated some big changes.  A lot of stuff has had to change under the hood to adjust to the fact that the raster package is being replaced by terra.  ENMTools depends very heavily on raster, so making this transition happen is quite a job.  A lot of other package authors are dealing with this right now as well, so the whole ecosystem is going to be a bit chaotic for the next little while.

We did create a branch on github that contains the last version of ENMTools that was designed for raster.  To install it just type:

devtools::install_github("danlwarren/ENMTools", ref = "raster")

Many of the changes we're making to deal with this are going to be invisible to users - just internal changes to the way data is handled.  In many cases it will speed up tests a bit, which is great.  However, a few of these changes will involve inevitable changes to the way that you set up your data for analysis in ENMTools.  Chief among these is that raster data will now need to be stored in terra's SpatRaster format and point data will be stored in terra's SpatVector format.  For the most part this is great - it allows us to allow these objects to have a CRS and projection attached to them, which is something we've been meaning to do for a while.  The one downside is that saving and loading these objects can be a bit of a hassle.

For that reason we're adding some new save and load functionality that should make this a little more easy to navigate.  The functions are "save.enmtools.species", "load.enmtools.species", "save.enmtools.clade", and "load.enmtools.clade".  

When you read in your own data from a .csv file, you'll want to convert it to a SpatVector object and specify a crs, like so:

my.data <- read.csv(path.to.file)

my.data <- terra::vect(my.data)

crs(my.data) <- "+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs" 

Where you replace "+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs" with the appropriate information for your data.  Loading in raster is much the same except you use terra::rast.

Unfortunately we've also had to disable a few functions.  The enmtools.hypervolume function is temporarily disabled, but we hope this won't be the case for long.  The authors of that package have adopted the terra framework on the version that's on github, but the version on CRAN isn't yet compatible.  We've also had to disable the GUESS recalibration model, because that package is spitting an error that we can't diagnose or work around.  The other recalibration methods still work, however.

Russell Dinnage and I have spent a lot of time hunting down bugs due to this changeover and planning even more big changes for ENMTools 2.0.  If you run into anything that doesn't work correctly, please do let us know - there's always the possibility that something has snuck by us.