I am using GPS data and the ctmm package to calculate home ranges for multiple individuals. The code runs without errors, but does contain warnings and produces incorrect results. A colleague used the same code and the same csv file on another computer without issue. I have gone as far as to copy and paste their code from email to ensure it was correct and tried multiple versions of R studio and have yet to find the issue. I have included a small sample of the data. I have also included the code and warnings after the line of code where they occur.
Id DateTime Latitude Longitude YearMonth
151_259_45_1 11/14/2007 0:00 27.4922397 -97.6223344 2007-11
151_259_45_1 11/14/2007 1:30 27.4922361 -97.6224614 2007-11
151_259_45_1 11/14/2007 2:00 27.4922217 -97.6225903 2007-11
151_259_45_1 12/4/2007 0:30 27.4851964 -97.6170192 2007-12
151_259_45_1 12/4/2007 3:00 27.4846739 -97.6277725 2007-12
151_259_45_1 12/4/2007 3:30 27.4854247 -97.6346442 2007-12
151_259_45_1 1/3/2008 14:30 27.4840406 -97.6196067 2008-01
151_259_45_1 1/3/2008 15:00 27.4840003 -97.6195778 2008-01
151_259_45_1 1/3/2008 15:30 27.4840381 -97.6196153 2008-01
#####Packages
library(sp)
library(rgdal)
library(move)
library(amt)
library(ggmap)
library(dplyr)
library(purrr)
library(tidyr)
library(lubridate)
library(adehabitatLT)
library(adehabitatMA)
library(raster)
library(mapview)
library(sf)
library(FNN)
library(ctmm)
#########Import Data
df<-read.csv("C:collars_sub.csv")
names(df)
unique(df$Id)
unique(df$YearMonth)
df$id2<-paste0(df$Id, df$YearMonth)
unique(df$id2)
df$DateTime2<-as.POSIXct(df$DateTime, format="%m/%d/%Y %H:%M")
df$DateTime2
############AKDE
deers<-df%>%
make_track(Longitude,Latitude,DateTime2,id=id2, crs = CRS("+proj=longlat"))
deers<-transform_coords(deers, sp::CRS("+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0"))
Warning messages:
In showSRID(uprojargs, format = "PROJ", multiline = "NO") :
Discarded datum North_American_Datum_1983 in CRS definition,
but +towgs84= values preserved
deers<-deers%>%
nest(data=c(x_, y_, t_))
#########calculate akde
akde<-deers%>%
mutate(hr_akde = map(data, ~ hr_akde(., fit_ctmm(., "ouf"))))
Warning message:
1: Problem with `mutate()` column `hr_akde`.
i `hr_akde = map(data, ~hr_akde(., fit_ctmm(., "ouf")))`.
i Discarded datum Unknown based on GRS80 ellipsoid in CRS definition,
but +towgs84= values preserved
########reformat to calculate hr sizes
hr_sizes_2 <- akde %>%
pivot_longer(hr_akde, names_to = "estimator", values_to = "hr")
#########calculate hr area
hr_sizes_2 <- hr_sizes_2 %>%
mutate(hr_area = map(hr, hr_area)) %>%
unnest(cols = hr_area)
###########We're not interested in LCI and UCI right now... get rid of
hr_sizes_3<-hr_sizes_2[hr_sizes_2$what=="estimate",]
#########look at each HR
for (i in 1:8) {
telem<-as_telemetry(hr_sizes_3$data[[i]])
plot(telem, UD=hr_sizes_3$hr[[i]]$akde,
main=paste(hr_sizes_3$id[[i]],hr_sizes_3$area[[i]]*3.861e-7), cex=.5)
compass()
}

