ctmm-initiative / ctmm

Continuous-Time Movement Modeling. Functions for identifying, fitting, and applying continuous-space, continuous-time stochastic movement models to animal tracking data.
http://biology.umd.edu/movement.html
43 stars 10 forks source link

rsf.fit() doesn't recognize terra SpatRasters #51

Open integratecology opened 9 months ago

integratecology commented 9 months ago

Hi Chris, I'm redoing some scripts to replace raster with terra, and if I run rsf.fit() on a terra raster loaded with terra::rast(), I get an error message that says:

"Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘cellStats’ for signature ‘"SpatRaster"’"

which I guess means rsf.fit() can't yet handle terra SpatRasters. terra's equivalent of cellStats() is global(), so I think this should be a pretty easy fix.

chfleming commented 9 months ago

I think the best way to handle differences between raster and terra is to call a wrapper function in rsf.fit, where the wrapper function calls the appropriate raster or terra function depending on the class of the object. I can start adding these functions as you come across incompatibilities. I'll put this one on the to-do list.

integratecology commented 3 months ago

Have you done this yet? I just tried to update an rsf.fit() script with a terra raster and it gave me the same error again