首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在adehabitatHR中为多个动物创建核密度估计

在adehabitatHR中为多个动物创建核密度估计
EN

Stack Overflow用户
提问于 2019-03-16 22:28:49
回答 1查看 607关注 0票数 2

我正在尝试创建核密度估计(KDEs)来估计多对长尾山雀的家范围。尽管过滤掉了少于5个GPS位置的对("nest_id“变量),但在尝试为所有个人创建kernelUD时,我仍然得到错误消息”至少需要5个重定位才能适应家庭范围“。我不确定到底是什么问题/我做错了什么。一般来说,我对家庭范围分析以及R和adehabitatHR都是非常陌生的。下面是我的代码。

代码语言:javascript
复制
library(dplyr)
# reading in location data
locations <- read.csv("./data/GPS_LOCATIONS_MASTER.csv")

## making nest_id a factor
locations$nest_id <- as.factor(locations$nest_id)

## filtering for points I want to include
location_sub <- filter(locations, start_at_nest == "no")

## taking out pairs (via nest_id) with less than 5 GPS locations
xorig <- subset(location_sub,
                with(location_sub,
                     nest_id %in% names(which(table(nest_id) >= 5))))

glimpse(xorig)


Observations: 257
Variables: 10
$ point_id          <int> 293, 294, 299, 300, 303, 306, 307, 312, 315, 318, 324…
$ nest_id           <fct> 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,…
$ female_id         <fct> RPR, RPR, RPR, RPR, RPR, RPR, RPR, RPR, RPR, RPR, RPR…
$ male_id           <fct> OWL, OWL, OWL, OWL, OWL, OWL, OWL, OWL, OWL, OWL, OWL…
$ lat               <dbl> 53.38293, 53.38285, 53.38282, 53.38302, 53.38300, 53.…
$ lon               <dbl> -1.554700, -1.554000, -1.553967, -1.554067, -1.553867…
$ start_at_nest     <fct> no, no, no, no, no, no, no, no, no, no, no, no, no, n…
$ place_in_sequence <int> 3, 1, 3, 4, 3, 3, 4, 3, 3, 3, 3, 4, 5, 1, 2, 3, 4, 5,…
$ date_time         <fct> 2019-02-27T13:26:31Z, 2019-02-27T13:28:46Z, 2019-02-2…
$ notes             <fct> , , , , , , , , , , , , , , , , , , , , , , , , , , 


library(sp)

## projecting so that my x & y (in coords.x1 & coords.x2) are in metres
xorig_s <- SpatialPointsDataFrame(xorig,
                                  coords = cbind(xorig$lon, xorig$lat),
                                  proj4string =  CRS("+proj=longlat +datum=WGS84 +no_defs"))
xorig_utm <- spTransform(xorig_s, CRS("+proj=utm +zone=30 +ellps=WGS84 
                                      +datum=WGS84 +units=m +no_defs"))
glimpse(as.data.frame(xorig_utm))

Observations: 257
Variables: 12
$ point_id          <int> 293, 294, 299, 300, 303, 306, 307, 312, 315, 318, 324…
$ nest_id           <fct> 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,…
$ female_id         <fct> RPR, RPR, RPR, RPR, RPR, RPR, RPR, RPR, RPR, RPR, RPR…
$ male_id           <fct> OWL, OWL, OWL, OWL, OWL, OWL, OWL, OWL, OWL, OWL, OWL…
$ lat               <dbl> 53.38293, 53.38285, 53.38282, 53.38302, 53.38300, 53.…
$ lon               <dbl> -1.554700, -1.554000, -1.553967, -1.554067, -1.553867…
$ start_at_nest     <fct> no, no, no, no, no, no, no, no, no, no, no, no, no, n…
$ place_in_sequence <int> 3, 1, 3, 4, 3, 3, 4, 3, 3, 3, 3, 4, 5, 1, 2, 3, 4, 5,…
$ date_time         <fct> 2019-02-27T13:26:31Z, 2019-02-27T13:28:46Z, 2019-02-2…
$ notes             <fct> , , , , , , , , , , , , , , , , , , , , , , , , , , 
$ coords.x1         <dbl> 596131.3, 596178.1, 596180.4, 596173.3, 596186.6, 596…
$ coords.x2         <dbl> 5915843, 5915835, 5915831, 5915853, 5915852, 5915848,…

library(adehabitatHR)

## trying to create :
kud <- kernelUD(xorig_utm[,1], h = "href")
## this procures the error message:
Error in kernelUD(xorig_utm[, 1], h = "href") : 
  At least 5 relocations are required to fit an home range
EN

回答 1

Stack Overflow用户

发布于 2019-04-08 17:28:57

已更新以指向kernelUD()函数文档的当前版本:

help docs for kernelUD

使用率

边界(xy,h= "href",grid = 60,same4all = FALSE,hlim = c(0.1,1.5),kern = c("bivnorm","epa"),extent = 1,kernelUD= NULL)

..。

参数

xy继承类SpatialPoints的对象,包含动物的x和y重定位。如果xy继承了SpatialPointsDataFrame类,那么它应该只包含一列(因子),对应于每次重新定位的动物的身份。

因此,使用上述方法时,您还可以在下面已经有示例的情况下使用Vignette

下面我使用puechabonsp数据集给出了一个使用kernelUD的简短示例。请记住,此数据集的组件relocs的第一列包含动物的身份:

data(Puechabonsp)> kud <- kernelUD(puechabonsp$relocs,1,h="href") > kud

要理解以上xy所需的内容,一种方法是打印出包example中包含的示例数据:

代码语言:javascript
复制
data("puechabonsp")
head( puechabonsp$relocs[,1] )


            coordinates  Name
    1 (699889, 3161560) Brock
    2 (700046, 3161540) Brock
    3 (698840, 3161030) Brock
    4 (699809, 3161500) Brock
    5 (698627, 3160940) Brock
    6 (698719, 3160990) Brock
    Coordinate Reference System (CRS) arguments: NA 

上面的注意,puechabonsp$relocs,1是一个包含坐标和ID (上面是‘SpatialPointsDataFrame’)的名称对象。

从这里开始,查看?SpatialPointsDataFrame帮助以了解该函数及其创建的对象:

使用率

SpatialPointsDataFrame(坐标,数据,coords.nrs =数字(0),proj4string = CRS(as.character(NA)),match.ID,bbox = NULL)

参数

将数值矩阵或类与坐标(每行是一个点)联系起来;如果是SpatialPointsDataFrame,也允许使用SpatialPoints- data.frame类的对象。

“你的任务,如果你选择接受...”在您的SpatialPointsDataFrame中正确创建coords,其中coords包括坐标和动物id。

从这里开始,提出一个新问题可能会有所帮助,比如“如何创建包含动物ids的SpatialPointsDataFrame?”如果你真的提出了这个问题,一定要包括一个可重复的数据集,因为这将对帮助你的人产生很大的影响。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55197856

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档