【问题标题】:Grid too small for kernelUD /getverticeshr/adehabitatHR home range estimation网格对于 kernelUD /getverticeshr/adehabitatHR 家庭范围估计来说太小了
【发布时间】:2017-05-31 17:38:43
【问题描述】:

adehabitat HR 的文档建议使用以下代码在创建 UD 对象后计算主范围的 95% 内核:

 ## Calculation of the 95 percent home range
    ver <- getverticeshr(ud, 95)

我的部分数据出现如下错误:

Error in getverticeshr.estUD(x[[i]], percent, ida = names(x)[i], unin,  : 
  The grid is too small to allow the estimation of home-range.
You should rerun kernelUD with a larger extent parameter

在 Nabble 论坛上,人们建议更改“网格”和“范围”输入,但在使用这两个参数的多种组合后,我无法获得更好的结果。有什么建议?

【问题讨论】:

    标签: r adehabitathr


    【解决方案1】:

    这是我在一些论坛中发现的常见问题。但答案很简单,而且就在错误信息中。 “你需要扩展你的网格”。发生这种情况是因为当您应用getverticeshr(ud, 95) 时,部分多边形超出了网格,因此无法获得区域。 例如,在下面的代码中,为两个假设的动物估计 KDE。我使用从 0 到 100 的随机点,所以我定义了一个 100x100(域)的网格。

    #"""
    # Language: R script
    # This is a temporary script file.
    #"""
    
    # 1. Packages
    library(adehabitatHR)         # Package for spatal analysis
    
    # 2. Empty Dataframe
    points <- data.frame(ID = double())
    XY_cor <- data.frame(X = double(),
                         Y = double())
    # 3. Assigning values (this will be our spatial coordinates)
    set.seed(17)
    for(i in c(1:100)){
        if(i >= 50){points[i, 1] <- 1}
        else {points[i, 1] <- 2}
        XY_cor[i, 1] <- runif(1, 0, 100)
        XY_cor[i, 2] <- runif(1, 0, 100)}
    
    # 4. Transform to SpatialDataframe
    coordinates(points) <- XY_cor[, c("X", "Y")]
    class(points)
    
    # 5. Domain
    x <- seq(0, 100, by=1.) # resolution is the pixel size you desire 
    y <- seq(0, 100, by=1.)
    xy <- expand.grid(x=x,y=y)
    coordinates(xy) <- ~x+y
    gridded(xy) <- TRUE
    class(xy)
    
    # 6. Kernel Density
    kud_points <- kernelUD(points, h = "href", grid = xy)
    image(kud_points)
    
    # 7. Get the Volum
    vud_points <- getvolumeUD(kud_points)
    
    # 8. Get contour
    levels <- c(50, 75, 95)
    list <- vector(mode="list", length = 2)
    
    list[[1]] <- as.image.SpatialGridDataFrame(vud_points[[1]])
    list[[2]] <- as.image.SpatialGridDataFrame(vud_points[[2]])
    
    # 9. Plot
    par(mfrow = c(2, 1))
    image(vud_points[[1]])
    contour(list[[1]], add=TRUE, levels=levels)
    image(vud_points[[2]])
    contour(list[[2]], add=TRUE, levels=levels)
    

    该图显示到 50% 的轮廓在网格内,但 75% 的轮廓被切割,这意味着该轮廓的一部分在外面。

    如果您尝试将 KDE 的顶点估计为 50%,您将获得很好的结果:

    # 10. Get vertices (It will be fine)
    vkde_points <- getverticeshr(kud_points, percent = 50,
                                     unin = 'm', unout='m2')
    plot(vkde_points)
    

    但如果你尝试使用 75% 的水平,你会得到经典错误:getverticeshr.estUD(x[[i]], percent, ida = names(x)[i], unin, 中的错误: 网格太小,无法估计归属范围。 您应该使用更大范围参数重新运行 kernelUD

    # 10. Get vertices (Will be an Error)
    vkde_points <- getverticeshr(kud_points, percent = 75,
                                     unin = 'm', unout='m2')
    plot(vkde_points)
    

    现在,您可以清楚地看到发生了什么,R 无法将顶点估计到 75%,因为它们在网格之外,因此您需要增加域(网格)!这里我将域增加50(见#5.Domain)

    # 5. Domain                 HERE GRID IS INCREASED 50 AT X AND Y!!
    x <- seq(-50, 150, by=1.) # resolution is the pixel size you desire 
    y <- seq(-50, 150, by=1.)
    xy <- expand.grid(x=x,y=y)
    coordinates(xy) <- ~x+y
    gridded(xy) <- TRUE
    class(xy)
    
    # 6. Kernel Density
    kud_points <- kernelUD(points, h = "href", grid = xy)
    image(kud_points)
    
    # 7. Get the Volum
    vud_points <- getvolumeUD(kud_points)
    
    # 8. Get contour
    levels <- c(50, 75, 95)
    list <- vector(mode="list", length = 2)
    
    list[[1]] <- as.image.SpatialGridDataFrame(vud_points[[1]])
    list[[2]] <- as.image.SpatialGridDataFrame(vud_points[[2]])
    
    # 9. Plot
    par(mfrow = c(2, 1))
    image(vud_points[[1]])
    contour(list[[1]], add=TRUE, levels=levels)
    image(vud_points[[2]])
    contour(list[[2]], add=TRUE, levels=levels)
    

    您可以看到所有轮廓都在网格(域)内。因此,现在您将能够估计顶点。

    # 10. Get vertices
    vkde_points <- getverticeshr(kud_points, percent = 75,
                                     unin = 'm', unout='m2')
    plot(vkde_points)
    

    【讨论】:

      猜你喜欢
      • 2019-02-20
      • 2021-10-11
      • 2021-11-09
      • 2021-08-16
      • 2015-10-01
      • 1970-01-01
      • 2017-07-28
      • 2020-07-16
      • 1970-01-01
      相关资源
      最近更新 更多