希望有人能帮忙,我有一个很大的数据集,我用相同的网格和h value=200生成了10个estUD。下面是其中两个的子集。我可以使用图像(Liud)对它们进行修改,但是当我尝试使用函数getverticeshr时,我会得到一个错误,即下标超出了范围。我尝试过更改网格和h的值,但没有结果。我想知道这是否与我将它们合并到列表中或从列表中删除的方式有关?
library(adehabitatHR)
#combine all Ud's into one dataset
liud <- list(Y2889a, Y2889b)
class(liud) <- "estUDm"
image(liud)#plot all est ud's
v<-getverticeshr(liud)我在下面的puechabonsp数据集中复制了错误。
library(adehabitatHR)
## Load the data
data(puechabonsp)
loc <- puechabonsp$relocs
## have a look at the data
head(as.data.frame(loc))
## the first column of this data frame is the ID
## Estimation of UD for each of the animals (two here as an example)
udBrock <- kernelUD(loc[as.data.frame(loc)[,1]=="Brock",], grid=200)
udCalou <- kernelUD(loc[as.data.frame(loc)[,1]=="Calou",], grid=200)
liud <- list(udBrock, udCalou)
class(liud) <- "estUDm"
image(liud)#plot all est ud's
v<-getverticeshr(liud)谢谢你的评论,克里斯,我应该解释我的数据集。我有10只动物,并根据记录的多边形为每种动物生成随机点。我给每只动物跑了100次。我的目标是在所有100次跑步的基础上为每只动物生成一个平均使用的分布。到目前为止,我已经使用了以下代码:
xybat <- subset(bat.master, bat.master$id =="Y2889a",select=x:loopno )
#change to spatial points
xy <- xybat[1:2]#first two rows save as coords
df <- xybat[-1:-3]#remove unneded columns for ud
SPDF <- SpatialPointsDataFrame(coords=xy, data=df)#combine df and xy
udHR <- kernelUD(SPDF, h = 200, grid=habitat, kernel=epa)
## I would proceed using the raster packages
ud <- stack(lapply(udHR, raster))
## You can now check the first one
plot(ud[[1]])
## or at all of them
#plot(ud)
## take the mean
plot(udm <- mean(ud))
## now you can either proceed in raster and calculate your isopleths or convert it back to a estUD, this is a bit of a hack and not the nicest way to do it
Y2889a<- udHR[[1]]
Y2889a@grid <- as(udm, "GridTopology")因此,如果我按照您的建议在整个数据集上运行kernelud函数,那么我仍然需要将每一个动物的ud分离项叠加起来,然后将它们组合成一个EstUDm,然后我又回到了相同的问题上。我希望你能帮我想出一个解决办法。
最美好的祝愿,西蒙妮
发布于 2014-12-12 13:28:55
这基本上只是对我以前回答的多种动物的一个概括,也许它是有用的:
library(adehabitatHR)
library(raster)
## generate some dummy data for 15 animals, each with 10 replications)
pts <- replicate(15, SpatialPointsDataFrame(coords=cbind(rnorm(1000), rnorm(1000)),
data=data.frame(id=rep(1:10, each=100))))
## generate uds
uds <- lapply(pts, function(x) kernelUD(x, h = "href", same4all = TRUE, kern = "bivnorm"))
udsr <- lapply(uds, function(x) stack(lapply(x, raster)))
## You can now check the first one
plot(udsr[[1]][[1]])
## or at all 10 uds of the first animal
plot(udsr[[1]])
## take the mean
udsm <- lapply(udsr, mean)
## go back to adehabitat
for (i in seq_along(udsm)) {
uds[[i]] <- uds[[i]][[1]]
uds[[i]]@grid <- as(udsm[[i]], "GridTopology")
}
## now you can work with udHR as if it were a HR estimate
iso95 <- lapply(uds, getverticeshr, percent=95)
## plot first animal
plot(iso95[[1]])
## plot second animal
plot(iso95[[2]])https://stackoverflow.com/questions/27376315
复制相似问题