Combining two or more estUDm objects into a single estUDm object

210 Views Asked by At

I know it is possible to combine multiple estUD objects into a single class-estUDm object using:

tot <- list(estUD1=estUD1, estUD2=estUD2, estUD3=estUD3)
class(tot) <- "estUDm"

However, is it possible to combine two or more estUDm objects into a single estUDm object? I have tried using the same principle; i.e.

tot <- list(estUDm1=estUDm1, estUDm2=estUDm2, estUDm3=estUDm3)
class(tot) <- "estUDm"

however, this results in the following error :

> tot
********** Utilization distribution of several Animals ************

Error in print.estUDm(x) : 
  trying to get slot "vol" from an object (class "estUDm") that is not an S4 object 

In my case, my objective is to run two KDE analyses with the same grid, but different smoothers (hence I end up with two estUDm objects), and then combine these to calculate the % overlap of polygons using kerneloverlaphr().

I have unsuccessfully tried to find / create alternative code that can calculate the overlap of multiple polygons in one go, hence my reliance on kerneloverlaphr().

1

There are 1 best solutions below

2
Ben On

This is a bit late, but because class-estUDm is just a list of class-estUD, I believe you can unlist to obtain class-estUD, concatenate these into a new list, then specify the estUDm class. An example below.

library(adehabitatHR)
library(sp)

#example data
data(puechabonsp)
dat <- puechabonsp$relocs
dat$Name <- as.character(dat$Name)

#split into two datasets
d1 <- dat[dat$Name == 'Brock' | dat$Name == 'Jean', ]
d2 <- dat[dat$Name != 'Brock' & dat$Name != 'Jean', ]

#get two lists of class estUDm
estUDm1 <- kernelUD(d1[ ,'Name'])
estUDm2 <- kernelUD(d2[ ,'Name'])

#unlist for class estuD
estUDm1 <- unlist(estUDm1)
estUDm2 <- unlist(estUDm2)

#concatenate to a new list
tot <- c(estUDm1, estUDm2)

#assign class estuDm
class(tot) <- "estUDm"
tot