Understanding the Error Message: A Closer Look at Grid Size and Extent in adehabitatHR
The getverticeshr function from the adehabitatHR package is used to estimate the home range of an animal based on a kernel density estimation. However, when this function is applied with a certain percentage value, it throws an error indicating that the grid size is too small to allow the estimation of the home range.
What Does the Error Message Say?
The error message reads:
“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”
What Does it Mean?
In essence, this error message tells us that the current grid size is not sufficient to accurately estimate the home range of the animal. To fix this, we need to increase the domain (grid) size.
Understanding Domain Size and Grid
- Domain Size: The domain size refers to the resolution or pixel size of the spatial grid used for the analysis.
- Grid: A grid is a two-dimensional array of coordinates that define the spatial boundaries within which the analysis will take place.
Increasing the Domain Size
To increase the domain size, we need to adjust the x and y values in the expand.grid() function. For example:
# 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)
In this example, we’re increasing the domain size to 100x100 pixels (i.e., a grid with a resolution of 1 pixel).
Why is Increasing Domain Size Necessary?
Increasing the domain size allows the getverticeshr function to include more points within the home range estimate. This is because a larger grid size provides a better representation of the spatial distribution of the animal’s activity.
By increasing the domain size, we can improve the accuracy of the home range estimate and get a more reliable result.
Example: Estimating Home Range with Increased Domain Size
Here’s an example of how to use getverticeshr with an increased domain size:
# 10. Get vertices (Will be an Error)
vkde_points <- getverticeshr(kud_points, percent = 75,
unin = 'm', unout='m2')
plot(vkde_points)
# 10. Get vertices (Will be Fine with Increased Domain Size)
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)
kud_points <- kernelUD(points, h = "href", grid = xy)
vud_points <- getvolumeUD(kud_points)
list <- vector(mode="list", length = 2)
list[[1]] <- as.image.SpatialGridDataFrame(vud_points[[1]])
list[[2]] <- as.image.SpatialGridDataFrame(vud_points[[2]])
par(mfrow = c(2, 1))
image(vud_points[[1]])
contour(list[[1]], add=TRUE, levels=c(50, 75, 95))
image(vud_points[[2]])
contour(list[[2]], add=TRUE, levels=c(50, 75, 95))
vkde_points <- getverticeshr(kud_points, percent = 75,
unin = 'm', unout='m2')
plot(vkde_points)
In this example, we’re using an increased domain size (100x100 pixels) to estimate the home range of the animal.
Plotting Results
After estimating the home range with the increased domain size, we can plot the results:
par(mfrow = c(2, 1))
image(vud_points[[1]])
contour(list[[1]], add=TRUE, levels=c(50, 75, 95))
image(vud_points[[2]])
contour(list[[2]], add=TRUE, levels=c(50, 75, 95))
vkde_points <- getverticeshr(kud_points, percent = 75,
unin = 'm', unout='m2')
plot(vkde_points)
In this example, we’re plotting the contour plot with the increased domain size.
Conclusion
Increasing the domain size is a necessary step in estimating home range using getverticeshr. By adjusting the grid size, we can improve the accuracy of the estimate and get a more reliable result.
Last modified on 2025-01-01