问题
I've created Kernel home ranges from gps locations using the tool kernelUD from the package(adehabitatHR) using the code:
'udKerHref <- kernelUD(data[,1],h = "href", grid=100, kern = c("bivnorm"))'
where data is a SpatialPointsDataFrame from 10 animals. I would now like to do two things:
- create a raster from the Kernel density values which I can multiply with another raster (Resource selection function raster)
- intersect other gps locations not used for building the home range with the raster built in 1 to extract the raster value at the given gps location
I tried to use the function 'estUDm2spixdf(x)' but I get the error
'Error in estUDm2spixdf(udKerHref) : this function can be used only when the same grid was used for all animals'
even though I used the same gris for all animals. And I also tried to get the raster using 'getVolumeUD and then export the object using 'writeRaster'. But I always got an error
'Error in (function (classes, fdef, mtable) :unable to find an inherited method for function ‘writeRaster’ for signature ‘"estUD", "character"’'
Any help is most appreciated
回答1:
Can't tell exactly what you've got without a reproducible example so I'm going to work with the udbis
object from help(kernelUD)
:
The object has a number of elements, and each can be coerced to a SpatialPixelsDataFrame and hence to a raster:
> names(udbis)
[1] "Brock" "Calou" "Chou" "Jean"
> plot(raster(as(udbis$Calou,"SpatialPixelsDataFrame")))
I suspect you've got ten elements there.
来源:https://stackoverflow.com/questions/26281735/r-how-to-create-raster-layer-from-an-estudm-object