I am using adehabitatHR to calculate the home ranges of several eagles. I would like to create a grid of 1 km x 1 km to input into the kernelUD function.
I tried to use the method as provided here: Creating an equal distance spatial grid in R
However, when I try to use this method it takes extremely long for R to compute the grid (I waited for over hour and then had to force quit R). This is because the area I am looking at is very large (the movement data spans several countries).
Is there another way of doing this or of speeding up the process, especially as I need to repeat this process for several individuals?
Below is an example of my script with the example buffalo dataset from the adehabitatHR vignette (I do not have permission to share my own data). Using the smaller data set, it works, but mine did not give an output even after waiting more than an hour.
library(adehabitatHR)
library(sp)
library(dplyr)
library (sf)
data(buffalo)
dat <- buffalo[["traj"]][[1]]
dat <- dplyr::select(dat, x, y, date)
dat$datetime <- as.POSIXct(dat$date, format = "%Y-%m-%d %hh:%mm:%ss")
dat$date <- as.Date(dat$datetime, format="%Y-%m-%d")
sp.UTM <- SpatialPoints(cbind(dat$x, dat$y), proj4string = CRS("+init=epsg:32632"))
# creating the grid using method proposed in other stackoverflow question (link above)
grid_spacing <- 1000
grid_buffalo <- st_make_grid(sp.UTM, square = T, cellsize = c(grid_spacing, grid_spacing)) %>%
st_sf()
sf.UTM <-st_as_sf(sp.UTM)
plot(grid_buffalo, col = 'white')
plot(st_geometry(sf.UTM), add = T)