i am trying to calculate KUD 50% and 95% for my penguin tracking data but have run into an error. My aim is to calculate the home range densities and then export the data as a polygon.
library(adehabitatHR)
library(sp)
library(readxl)
library(rgdal)
HRtracks<- as.data.frame(read_excel("allinterpolatedtracks.xlsx"))
# assign the correct columns as coordinates
coordinates(HRtracks)<-c("x","y")
proj4string(HRtracks)<- CRS("+init=epsg:3857")
#convert the coordinates to utm format
tracks.utm<-spTransform(HRtracks, CRS("+proj=utm +zone=60 +datum=WGS84"))
Error occurs after running this part of the script, tracks.utm[,X] indicates the column the data is sorted by, which is by individual tripID so it should create a range for each separate track.
colkud<-kernelUD(tracks.utm[,3],h="href", grid=1000,same4all=T)
The error:
Error: Can't subset columns that don't exist.
x Location 3 doesn't exist.
i There are only 1 column.
I suspect i am missing something in my script, however i am not an experienced user as of yet so hoping to get some advice.
The data:
tracks.utm <- dput(new("SpatialPointsDataFrame", data = structure(list(TripID = c(1,
1, 1, 1, 1, 1)), row.names = c(NA, -6L), class = c("data.frame")),
coords.nrs = numeric(0), coords = structure(c(165846.488217799,
165846.488227808, 165846.488167749, 165846.488257839, 165846.488237819,
165846.488718291, -19995889.0262206, -19995889.0261311, -19995889.0262007,
-19995889.0261311, -19995889.0260814, -19995889.0254053), .Dim = c(6L,
2L), .Dimnames = list(NULL, c("x", "y"))), bbox = structure(c(165846.488167749,
-19995889.0262206, 165846.488718291, -19995889.0254053), .Dim = c(2L,
2L), .Dimnames = list(c("x", "y"), c("min", "max"))), proj4string = new("CRS",
projargs = "+proj=utm +zone=60 +datum=WGS84 +units=m +no_defs")))
Cheers