2

I have used the package adehabitatHR in R to estimate the utilization distribution (UD) of a bird using a custom grid

#make the custom grid
x <- seq(-1723705, 2511295, by = 5000) 
y <- seq(7085019, 9240019, by = 5000)
xy <- expand.grid(x=x,y=y)
coordinates(xy) <- ~x+y
gridded(xy) <- TRUE
class(xy)

kde.blsc <- kernelUD(blsc.ptt, h = "href", grid = xy)

#kde.blsc is an `estUD` object
summary(kde.blsc)

I would now like to extract the UD values from kde.blsc to either a SpatialPixelsDataFrame or a SpatialPolygonsDataFrame, so that I can link it to habitat variables saved in a separate SpatialPolygonsDataFrame.

However, when I try to use the function estUDm2spixdf, I get the following error:

blsc.pix <- estUDm2spixdf(kde.blsc)

Error in estUDm2spixdf(kde.blsc) : x should be of class "estUDm"

How can I turn kde.blsc into a estUDm object? Or are there any alternative methods?

1 Answer 1

2

Admittedly, the object structures from the adehabitat packages can be very difficult to deal with and are quite obtuse. I believe that in your case, the resulting object is functionally a list object with the class estUD. You should be able to reference an specific KDE (UD) using a double bracket and coerce using as. Try this and let me know if it works.

Load data and estimate UD for the four animals

library(sp)
library(adehabitatHR)

data(puechabonsp)
  loc <- puechabonsp$relocs

( ud <- kernelUD(loc[,1]))
  names(ud)

Extract a specific KDE from the list object and coerce to "SpatialPixelsDataFrame"

ud1 <- as(ud[[1]], "SpatialPixelsDataFrame")
  class(ud1) 
  head(ud1@data) 
  plot(ud1)

If you are wanting to extract pixel values, to get a zonal summary of some sort, you can go straight to a raster class object and then use raster::extract.

library(raster)
  ud1 <- raster(as(ud[[1]], "SpatialPixelsDataFrame"))
    class(ud1) 
    plot(ud1) 
extract(ud1, loc[,1]) # extract point values for x,y used in UD est

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.