我正在尝试为我的企鹅跟踪数据计算 KUD 50% 和 95%,但遇到了错误。我的目标是计算家庭范围密度,然后将数据导出为多边形。
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"))
运行这部分脚本后发生错误,tracks.utm[,X] 表示数据排序的列,它是按单独的tripID,因此它应该为每个单独的轨道创建一个范围。
colkud<-kernelUD(tracks.utm[,3],h="href", grid=1000,same4all=T)
错误:
Error: Can't subset columns that don't exist.
x Location 3 doesn't exist.
i There are only 1 column.
我怀疑我的脚本中遗漏了一些东西,但是我还不是一个有经验的用户,所以希望得到一些建议。
数据:
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")))
干杯