0

I need to create a move-object from a large set of telemetric data (>100,000 rows) for e.g. brownian bridge movement modelling. I spent a lot of time today to be sure about the format of the columns but the move()-function still does not work. This is how the head of my data looks like:

> head(gps)
# A tibble: 6 x 6
     id UTC_date   UTC_time   Lat  Long datetime           
  <dbl> <date>     <time>   <dbl> <dbl> <dttm>             
1     1 2022-03-01 04:32:36  47.6  17.2 2022-03-01 04:32:36
2     2 2022-03-01 05:09:09  47.6  17.2 2022-03-01 05:09:09
3     3 2022-03-01 05:24:36  47.6  17.2 2022-03-01 05:24:36
4     4 2022-03-01 05:39:11  47.6  17.2 2022-03-01 05:39:11
5     5 2022-03-01 05:54:10  47.6  17.2 2022-03-01 05:54:10
6     6 2022-03-01 06:09:07  47.6  17.2 2022-03-01 06:09:07

So this is the code I applied:

> gps.move <- move(x=gps$Long,y=gps$Lat,time=as.POSIXct(gps$datetime, format="%Y-%m-%d %H:%M:%S", tz="UTC"), proj=CRS("+proj=longlat +ellps=WGS84"),sensor='gps',animal='ebr')

Which leads to the following error:

Error in validityMethod(as(object, superClass)) : 
  There are NA timestamps records

There are no NAs in my dataset and everything looks fine. The format of the datetime column should be ok. So its not the same issue as for question "Attempting to make a Move object in R - NA timestamp records" which has been answered, already.

No idea what more I can do, but so far I can't even start my analyses... So if anybody could help, it would be great!!! Waiting for your ideas, Vincent

according to the comment by akrun, I provide an example of my dataset via

dput(head(gps, 30))

structure(list(id = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 
29, 30), UTC_date = structure(c(19052, 19052, 19052, 19052, 19052, 
19052, 19052, 19052, 19052, 19052, 19052, 19052, 19052, 19052, 
19052, 19052, 19052, 19052, 19052, 19052, 19052, 19052, 19052, 
19052, 19052, 19052, 19052, 19052, 19052, 19052), class = "Date"), 
    UTC_time = structure(c(16356, 18549, 19476, 20351, 21250, 
    22147, 23044, 23946, 24849, 25762, 26646, 27549, 28475, 29350, 
    30244, 31144, 32054, 32943, 33843, 34143, 34443, 34748, 35046, 
    35355, 35646, 35944, 36250, 36549, 36847, 37155), class = c("hms", 
    "difftime"), units = "secs"), Lat = c(47.640568, 47.640465, 
    47.640583, 47.634518, 47.634521, 47.634571, 47.628986, 47.615341, 
    47.616413, 47.615879, 47.610222, 47.610355, 47.610271, 47.601887, 
    47.590824, 47.630959, 47.667355, 47.661449, 47.657658, 47.663628, 
    47.665482, 47.67421, 47.682339, 47.690842, 47.68565, 47.684284, 
    47.680889, 47.683617, 47.687698, 47.70435), Long = c(17.16995, 
    17.169903, 17.170017, 17.171446, 17.171473, 17.171505, 17.156851, 
    17.146259, 17.144289, 17.145241, 17.145254, 17.144869, 17.144958, 
    17.162409, 17.182302, 17.179539, 17.175821, 17.212822, 17.216106, 
    17.213263, 17.217554, 17.209574, 17.207357, 17.188231, 17.155718, 
    17.139551, 17.143511, 17.133562, 17.136698, 17.111744), datetime = structure(c(1646105556, 
    1646107749, 1646108676, 1646109551, 1646110450, 1646111347, 
    1646112244, 1646113146, 1646114049, 1646114962, 1646115846, 
    1646116749, 1646117675, 1646118550, 1646119444, 1646120344, 
    1646121254, 1646122143, 1646123043, 1646123343, 1646123643, 
    1646123948, 1646124246, 1646124555, 1646124846, 1646125144, 
    1646125450, 1646125749, 1646126047, 1646126355), tzone = "", class = c("POSIXct", 
    "POSIXt"))), row.names = c(NA, -30L), class = c("tbl_df", 
"tbl", "data.frame"))
Vincent
  • 1
  • 1
  • The `gps$datetime` is already `POSIXct`. you don't need to convert it again. It is possible that while doing the conversion again, there could be some elements that converted to NA. Try `move(x = gps$Long, y = gps$Lat, time = gps$datetime, proj=CRS("+proj=longlat +ellps=WGS84"),sensor='gps',animal='ebr')` – akrun Aug 06 '22 at 17:20
  • Hey akrun! Thanks for having a look. However, I tried your piece of code but nothing changes. Still the same error message... – Vincent Aug 06 '22 at 17:32
  • Do you have `sum(is.na(gps$datetime))` greater than 0. If that doesn't work, can you update your post with a small reproducible example that shows the error i.e. using `dput(head(gps, 30))` – akrun Aug 06 '22 at 17:33
  • with `100000` records, it is not easy to check manually for NAs unless you have already done `sum(is.na(gps$datetime))` earlier (I didn't see that in the code) – akrun Aug 06 '22 at 17:38
  • I tried sum(is.na(gps$datetime)) and received 1. – Vincent Aug 06 '22 at 17:41
  • So, there is one NA in the whole data. You can use `gps1 <- na.omit(gps)` and then run it on `gps1` – akrun Aug 06 '22 at 17:42
  • gps1 <- na.omit(gps) OK i tried...move(x = gps1$Long, y = gps1$Lat, time = gps1$datetime, proj=CRS("+proj=longlat +ellps=WGS84"),sensor='gps',animal='ebr') Error in validityMethod(as(object, superClass)) : The dataset includes timestamps that are not ascending – Vincent Aug 06 '22 at 17:47
  • ok I tried, and it had at least an effect on the error message...but still, there seems to be a problem with the timestamps. – Vincent Aug 06 '22 at 17:48
  • ok, sorry, as I said your post is not reproducible for others to test – akrun Aug 06 '22 at 17:49
  • I will search for questions on that and maybe come back, afterwards. But thank you, so far for your support!!! – Vincent Aug 06 '22 at 17:50
  • 1
    Ok, after the second error message I removed duplicates via distinct function from dplyr package : gps2<- gps1 %>% distinct(datetime, .keep_all = TRUE) which finally brought the move function to work!! Thank you, akrun for pointing me in the right direction! – Vincent Aug 06 '22 at 18:45
  • I guess datetime, should not be duplicated. Thanks for letting me know – akrun Aug 06 '22 at 18:51

0 Answers0