内核中的错误UD "at least 5 relocations are required to fit a home range"



我有一个多边形形式的蝙蝠运动数据集。我为每个多边形创建了一个随机点,并循环运行100次。这创建了一个数据框架,其中每个蝙蝠有100个环路。我试图为每个循环创建一个kernelUD,每个人堆叠它们,然后使用以下脚本平均它们。当我使用完整的数据集时,这是有效的。然而,当我对它进行抽样时,我得到的错误是"至少需要5次重新定位才能适应家庭范围"。请有人告诉我最好的方法来检查我有多少重新定位每个循环或个人请?

library(adehabitatHR)
library(raster)
library(maptools)
library(stats)
setwd("C:/Users/a6915409/Dropbox/Paper write up")

# read in bat master
bat.master<- read.csv("./original csv files/LCfirsthalf09.09.csv")
#make bat.points spatial data
xy <- bat.master[2:3]#first two rows save as coords
df <- bat.master [-1:-4]#remove unneded columns for ud
df<-df[-2]
SPDF <- SpatialPointsDataFrame(coords=xy, data=df)#combine df and xy
#read in landcover data for habitat grid
r <- raster("landcover.asc")
#need to set up graphical parametrs
par(mfrow=c(2,1))
par(mar=c(0,0,2,0))
g <- as(r, 'SpatialGridDataFrame')
p <- as(r, 'SpatialPixelsDataFrame')
habitat<-p
#chnage spatial projections so they match
proj4string(SPDF)<-proj4string(habitat)
#split bat master by ID into a list of spatial dataframes each with 100 replicates 
pts1<-split(SPDF , bat.master$id)
 ## generate uds on each animal for each loop
pts2 <- lapply(pts1, function(x) {slot(x, "data") <- data.frame(x@data   [,1]); return(x)})
############################################################## Works up to  here

  uds<- lapply(pts2, function(x) kernelUD(x, h=200, grid=habitat))#flags an error "at least 5 relocations are required to fit an home range"
#stack the ud's as raster layers, 100 for each animal
udsr <- lapply(uds, function(x) stack(lapply(x, raster)))

## take the mean
udsm <- lapply(udsr, mean)
for (i in seq_along(udsm)) {
  uds[[i]]<- uds[[i]][[1]]
  uds[[i]]@grid <- as(udsm[[i]], "GridTopology")
}

class(uds)<-"estUDm"

这是这个问题的解决方案,

#read in csv file
bat.master<- read.csv("./CLUSTERS NEW/LC1point10loops.csv")
library(dplyr)
#check if any bats have less than 5 relocations using dplyr
check<- bat.master%>%group_by(id, loopno)%>%summarise(loop=length(loopno))% >%dplyr::filter(loop<6)
#convert this to a dataframe
check<- as.data.frame(check)
#subset bat.master to exclude those individuals found to have less than 5 relocations
bat.master<-bat.master %>% anti_join(check)
# proceed with rest of code

相关内容

  • 没有找到相关文章

最新更新