I created kernel densities/utilization distributions for multiple animals in ArcGIS Pro instead of using the adehabitatHR package in R because I needed a different smoothing parameter estimator and I had a difficult boundary to work with.
Now I have several individual raster files of these UDs and I want to calculate overlap using the UDOI method. This would be much more efficient using the adehabitatHR package, but I'm having trouble converting these rasters into a single estUDm object to use with the kerneloverlaphr function. I apologize, I am not sure how to provide the rasters to create reproducible data, but my code is below.
I appreciate any help with this error message that I'm receiving when running kerneloverlaphr: "Error in if (slot(x[[1]], "vol")) stop("x should not be a volume under UD") : argument is of length zero"
library(raster)
library(adehabitatHR)
#Import kernel density rasters created in ArcGIS Pro
UD1 <- raster("UD1.tif")
UD2 <- raster("UD2.tif")
#Convert to spatial pixels data frame
UD1.px <- as(UD1, "SpatialPixelsDataFrame")
UD2.px <- as(UD2, "SpatialPixelsDataFrame")
#Convert to estUD
UD1.estUD <- new("estUD", UD1.px)
UD2.estUD <- new("estUD", UD2.px)
#Combine both estUD's and convert to estUDm for overlap analysis
UD.combined <- list(animal1=UD1.estUD, animal2=UD2.estUD)
class(UD.combined) <- "estUDm"
#Check individual UD's
plot(UD.combined$animal1) #shows correct UD
plot(UD.combined$animal2) #shows correct UD
kerneloverlaphr(UD.combined, method=c("UDOI")) #Received error message: Error in if (slot(x[[1]], "vol")) stop("x should not be a volume under UD") : argument is of length zero
I think you will need to specify values for the slots of an object of class estUD. The creator of the package has provided an example that I found on this mailing list.
https://www.mail-archive.com/[email protected]/msg00455.html
Here's an example for your problem of calculating overlap. We can simulate loading in external rasters by just creating them from a SpatialPointsDataFrame provided from adehabitatHR.