Hi all, I am using R version 2.14.2 on a Windows 7 machine and adehabitatHR version 0.4.2.
I have an extensive database of dolphin locations and would like to look at home range overlap between animals. My study area has a complex coastline and does not work with the "boundary" slot in the kernelUD function. I was able to clip out the land using the method devised by Tony Fischback and Clement Calenge in the following post http://r-sig-geo.2731867.n2.nabble.com/Walruses-and-adehabitatHR-class-estUDm-exclusion-of-non-habitat-pixels-and-summary-over-all-animals-td6497315.html. The above method requires coversion of the kernelUD output (of class-estUDm) into a SpatialPixelsDataFrame. Once the land is clipped out, I successfully converted the object back into class-estUDm. However, when I try to run the kerneloverlaphr function with the converted file, I get 0 for every overlap (which should not be the case). Kerneloverlaphr works fine if I run it using the kernelUDs before the land is clipped out, but not after. I have no idea why it's not working properly, but it must have something to do with the process of clipping out the land. Any advice on the matter would be greatly appreciated. I have included an example of my code using the data(puechabonsp) that comes with the adehabitatHR package. # Load data data(puechabonsp) # Store relocations loc <- puechabonsp$relocs # Store map elev <- puechabonsp$map # Build "fake" habitat map (1= habitat, 0 = non habitat) fullgrid(elev) <- TRUE hab <- elev hab[[1]] <- as.numeric(!is.na(hab[[1]])) # Convert hab back into SpatialPixelsDataFrame (as needed for kernelUD function) hab <- as(hab, "SpatialPixelsDataFrame") # Estimate UD ud <- kernelUD(loc[,1], grid=hab) # Convert to SpatialPixelsDataFrame udspdf <- estUDm2spixdf(ud) # Convert resulting file to fullgrid fullgrid(udspdf) <- TRUE # Convert habitat map to fullgrid fullgrid(hab)<-TRUE # Multiply each column of udspdf by the habitat variable resu <- lapply(1:ncol(udspdf), function(i) {udspdf[[i]] * hab[[1]] / sum(udspdf[[i]] * hab[[1]])}) resu <- as.data.frame(resu) names(resu) <- names(udspdf@data) # Define it as a data slot for udspdf udspdf@data <- resu # Convert to SpatialPixelsDataFrame fullgrid(udspdf) <- FALSE # Convert result back into class estUDm re <- lapply(1:ncol(udspdf), function(i) { so <- new("estUD", udspdf[,i]) so@h <- list(h=0, meth="specified") # fake value so@vol <- FALSE return(so) }) names(re) <- names(udspdf) class(re) <- "estUDm" # Find kernel overlap kov_clipped <- kerneloverlaphr(re, method = "PHR", percent = 95, conditional = FALSE) # Result is all zeros (copied directly from R window) > kov_clipped Brock Calou Chou Jean Brock 0 0 0 0 Calou 0 0 0 0 Chou 0 0 0 0 Jean 0 0 0 0 # Run kernel overlap for non-clipped UDs (to test accuracy of the above) kov_nonclipped <- kerneloverlaphr(ud, method = "PHR", percent = 95, conditional = FALSE) # Result is not all zeros (copied directly from R window) > kov_nonclipped Brock Calou Chou Jean Brock 0.94933028 0.7198043 0.0000000 0.02139490 Calou 0.30917730 0.9495502 0.0000000 0.02949861 Chou 0.00000000 0.0000000 0.9496367 0.89242679 Jean 0.04359732 0.3086748 0.9122472 0.94957049 Thanks so much for your time and assistance! Liz ----------- Liz Hartel Biological Scientist Population Biology and Behavioral Ecology Harbor Branch Oceanographic Institute - FAU 5600 US 1 North, Fort Pierce, FL 34946 work: (772) 242-2238 cell: (772) 216-4363 www.hboi.fau.edu -- View this message in context: http://r-sig-geo.2731867.n2.nabble.com/complex-coastline-and-adehabitatHR-trouble-with-kerneloverlaphr-function-after-coastline-has-been-clt-tp7581851.html Sent from the R-sig-geo mailing list archive at Nabble.com. _______________________________________________ R-sig-Geo mailing list [email protected] https://stat.ethz.ch/mailman/listinfo/r-sig-geo
