R: how to create raster layer from an estUDm object

久未见 提交于 2019-12-12 04:52:57

问题


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:

  1. create a raster from the Kernel density values which I can multiply with another raster (Resource selection function raster)
  2. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!