Error in calculating UDs in same grid

42 views
Skip to first unread message

Jocelyn Stalker

unread,
May 12, 2022, 4:56:32 PMMay 12
to ctmm R user group
When following the code example in the documentation for the overlap function to create aligned UDs, I get the following error: "Data not in single coordinate system". I've looked at the source code to see that that error is thrown when length(projection(data)) >1, but when I run that it returns a value of 1.

Here is my code:
guess <- lapply(nest.test$data, function(g) ctmm.guess(g, interactive= FALSE))
fits <- lapply(1:length(guess), function(i) ctmm.select(nest.test$data[[i]], guess[[i]]))
uds <- akde(nest.test$data, fits)
#Error in akde(nest.test$data, fits) :
#  Data not in single coordinate system.
overlap(uds)

I will e-mail you now with a copy of my dataset, but I wanted to post this publicly in case the answer is helpful to others.

Jocelyn

Jocelyn Stalker

unread,
May 12, 2022, 5:18:02 PMMay 12
to ctmm R user group
Someone referenced a similar problem here, but implementing the solution that worked for them throws another error:

dat <- nest.test$data[1:6]
projection(dat) <- median(dat)
#Error in (function (cl, name, valueClass)  :
#  ‘crs’ is not a slot in class “list”

Christen Fleming

unread,
May 13, 2022, 7:05:49 AMMay 13
to ctmm R user group
Hi Jocelyn,

The re-projection line works for me. I'm guessing you have another package loaded that is overriding the projection()<- method. I would try to run the code in a fresh session with out having other packages loaded, and when loading packages look for messages like:

Attaching package: ‘package2’

The following objects are masked from ‘package:package1’:

    function1,  function2 ,  function3 ,  function4

Alternatively, you could try to run the function ctmm::projection()<- , to specify which package's projection assignment function you want to call.

Best,
Chris

Jocelyn Stalker

unread,
May 16, 2022, 11:12:35 PMMay 16
to ctmm R user group
Thanks Chris, that was the issue!

I've got another question about UDs on the same grid: when I use the plot() function in ctmm on UDs that are calculated on the same grid and in the same projection, they still have grid lines that don't align (the white ones). Does this imply that the UDs are not plotting in the correct spatial configuration?

Jocelyn

Christen Fleming

unread,
May 17, 2022, 11:13:33 AMMay 17
to ctmm R user group
Hi Jocelyn,

Those grid lines denote the spatial resolution via the bandwidth, which is oriented with the distribution. You can turn them off with col.grid=NA. I'll add that to the documentation.

Best,
Chris
Reply all
Reply to author
Forward
0 new messages