Stuck with different no. of rows for Calculating kernel density UDOI in R. How to proceed?

32 Views Asked by At

I see a couple of unanswered similar questions for the same topic and the best one so far has been this one but I cannot proceed with my UDOI for kernel densities after using that script due to "unequal no. of rows", which I don't know how to change. I am getting the following message when I try to use my final code for UDOI as per the mentioned page above:

kerneloverlaphr(UD.combined, method=c("UDOI")) 
    
    animal1 animal2

animal1       0       0
animal2       0       0
Warning messages:
1: In ai * aj :
  longer object length is not a multiple of shorter object length
2: In vi * vj :
  longer object length is not a multiple of shorter object length

If I try to use the other code, similar error comes up:

kerneloverlap(UDpix.combined, method=c("UDOI")) 

Error in h(simpleError(msg, call)) : error in evaluating the argument 'obj' in selecting a method for function 'coordinates': arguments imply differing number of rows: 48906, 56244

How do I change the number of rows for my raster? I don't understand. Full code for the study is this:

setwd('')

#Import kernel density rasters created in ArcGIS Pro
UD1 <- raster("example1.tif")
UD2 <- raster("example2.tif")

#Convert to spatial pixels data frame
UD1.px <- as(UD1, "SpatialPixelsDataFrame")
UD2.px <- as(UD2, "SpatialPixelsDataFrame")

#define parameters and slots for estUD
fullgrid(UD1.px) <- FALSE
fullgrid(UD2.px) <- FALSE

hli <- list(h = 1, meth="specified")

UD1.estUD <- new("estUD", UD1.px)
slot(UD1.estUD, "h") <- hli
slot(UD1.estUD, "vol") <- FALSE

UD2.estUD <- new("estUD", UD2.px)
slot(UD2.estUD, "h") <- hli
slot(UD2.estUD, "vol") <- FALSE


#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

length(UD1.estUD)
length(UD2.estUD)

kerneloverlaphr(UD.combined, method=c("UDOI")) 
 

OR

 UDpix.combined <- list(animal1=UD1.px, animal2=UD2.px)
    kerneloverlap(UDpix.combined, method=c("UDOI"))

Update: I also tried to export the raster file from ArcGIS with an equal extent for each file. Even so it doesn't help.

0

There are 0 best solutions below