"Invalid layer names" error with raster grid in occurrence function

408 views
Skip to first unread message

Jenny Hansen

unread,
Jul 13, 2022, 3:09:37 AM7/13/22
to ctmm R user group
Hi Chris,
  I am attempting to get the occurrence distribution of all the females in my study population using a common grid. I have used this raster grid successfully with the AKDE function in order to get overlap values for the females' UDs. However, I am getting an error when I try to use the same raster grid in the occurrence function.

Running the following code:

ODs <- vector("list", length = 240)

for(i in 1:length(fem_telem)){
 
  cat(paste("Estimating Occurrence distribution of individual", i))
 
  ODs[[i]] <- occurrence(fem_telem[[i]], models[[i]], variable = "utilization", grid = density)
 
}

produces an error "invalid layer names." Using traceback, it appears to be an issue with the grid.

Error in .local(x, ...) : invalid layer names
12. stop("invalid layer names")
11. .local(x, ...)
10. subset(x, i, drop = drop)
9. subset(x, i, drop = drop)
8. .local(x, i, j, ...)
7. x[[name]]
6. x[[name]]
5. grid$r
4. grid$r
3. kde.grid(data, H = H, axes = axes, alpha = alpha, res = res,
         dr = dr, grid = grid)
2. kde(data, H = H, W = w.grid, dr = dr/res.space, grid = grid)
1. occurrence(fem_telem[[i]], models[[i]], variable = "utilization",
    grid = density)


 When I run the function without the grid, I have no problems, e.g.

test_od <- occurrence(t_1, m_1, variable = "utilization") runs just fine.

Do you have any idea how I might adjust the properties of my raster grid to avoid this error? Thanks in advance!

Jenny

Christen Fleming

unread,
Jul 13, 2022, 4:45:12 PM7/13/22
to ctmm R user group
Hi Jenny,

This sounds like it should work. Can you send me a minimal working example to look at (either with the files or from a Dropbox)?

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