Interface to other packages with amt

Johannes Signer

2020-04-23

About

This vignette briefly introduces how one can coerce amt track_xy* to other commonly used packages. At the moment this vignette shows methods to coerce to adehabitatHR, ctmm, and move.

Getting the data ready

First we load the required libraries and the relocation data (called deer)

library(amt)
data("deer")
deer
## # A tibble: 826 x 4
##          x_       y_ t_                  burst_
##  *    <dbl>    <dbl> <dttm>               <dbl>
##  1 4314068. 3445807. 2008-03-30 00:01:47      1
##  2 4314053. 3445768. 2008-03-30 06:00:54      1
##  3 4314105. 3445859. 2008-03-30 12:01:47      1
##  4 4314044. 3445785. 2008-03-30 18:01:24      1
##  5 4313015. 3445858. 2008-03-31 00:01:23      1
##  6 4312860. 3445857. 2008-03-31 06:01:45      1
##  7 4312854. 3445856. 2008-03-31 12:01:11      1
##  8 4312858. 3445858. 2008-03-31 18:01:55      1
##  9 4312745. 3445862. 2008-04-01 00:01:24      1
## 10 4312651. 3446024. 2008-04-01 06:00:54      1
## # … with 816 more rows

adehbatit*

adehabitatLT_ltraj <- as_ltraj(deer)
adehabitatLT_ltraj
## 
## *********** List of class ltraj ***********
## 
## Type of the traject: Type II (time recorded)
## * Time zone: UTC *
## Irregular traject. Variable time lag between two locs
## 
## Characteristics of the bursts:
##         id    burst nb.reloc NAs          date.begin            date.end
## 1 animal_1 animal_1      826   0 2008-03-30 00:01:47 2009-04-28 00:00:21
## 
## 
##  infolocs provided. The following variables are available:
## [1] "pkey"

ctmm

With the function as_telemetry a track_xyt can be coerced to a telemetry object used in ctmm.

ctmm_obj <- as_telemetry(deer)
class(ctmm_obj)
## [1] "telemetry"
## attr(,"package")
## [1] "ctmm"

move

move_obj <- as_move(deer)
move_obj
## class       : Move 
## features    : 826 
## extent      : 4309723, 4318383, 3442716, 3450713  (xmin, xmax, ymin, ymax)
## crs         : +init=epsg:3035 +proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs 
## variables   : 1
## names       : burst_ 
## min values  :      1 
## max values  :     35 
## timestamps  : 2008-03-30 00:01:47 ... 2009-04-28 00:00:21 Time difference of 394 days  (start ... end, duration) 
## sensors     : unknown 
## indiv. data :  
## indiv. value:  
## date created: 2019-09-18 13:45:25.315127

To sf and sp

Session

sessioninfo::session_info()
## ─ Session info ───────────────────────────────────────────────────────────────
##  setting  value                       
##  version  R version 3.6.3 (2020-02-29)
##  os       Ubuntu 18.04.4 LTS          
##  system   x86_64, linux-gnu           
##  ui       X11                         
##  language en_US:en                    
##  collate  C                           
##  ctype    en_US.UTF-8                 
##  tz       Europe/Berlin               
##  date     2020-04-23                  
## 
## ─ Packages ───────────────────────────────────────────────────────────────────
##  package      * version    date       lib source                           
##  ade4           1.7-13     2018-08-31 [3] CRAN (R 3.6.1)                   
##  adehabitatLT   0.3.24     2019-04-07 [3] CRAN (R 3.6.1)                   
##  adehabitatMA   0.3.13     2019-04-07 [3] CRAN (R 3.6.1)                   
##  amt          * 0.1.0      2020-04-23 [1] local                            
##  assertthat     0.2.1      2019-03-21 [3] CRAN (R 3.6.1)                   
##  backports      1.1.6      2020-04-05 [3] CRAN (R 3.6.3)                   
##  boot           1.3-24     2019-12-20 [6] CRAN (R 3.6.2)                   
##  callr          3.4.3      2020-03-28 [3] CRAN (R 3.6.3)                   
##  checkmate      2.0.0      2020-02-06 [3] CRAN (R 3.6.1)                   
##  CircStats      0.2-6      2018-07-01 [3] CRAN (R 3.6.1)                   
##  circular       0.4-93     2017-06-29 [3] CRAN (R 3.6.1)                   
##  class          7.3-15     2019-01-01 [6] CRAN (R 3.6.0)                   
##  classInt       0.4-2      2019-10-17 [3] CRAN (R 3.6.1)                   
##  cli            2.0.2      2020-02-28 [3] CRAN (R 3.6.1)                   
##  codetools      0.2-16     2018-12-24 [6] CRAN (R 3.6.0)                   
##  colorspace     1.4-1      2019-03-18 [3] CRAN (R 3.6.1)                   
##  crayon         1.3.4      2017-09-16 [3] CRAN (R 3.6.1)                   
##  ctmm           0.5.9      2020-03-23 [3] CRAN (R 3.6.3)                   
##  DBI            1.1.0      2019-12-15 [3] CRAN (R 3.6.1)                   
##  DEoptimR       1.0-8      2016-11-19 [3] CRAN (R 3.6.1)                   
##  desc           1.2.0      2018-05-01 [3] CRAN (R 3.6.1)                   
##  devtools       2.2.2.9000 2020-04-23 [3] Github (r-lib/devtools@b166195)  
##  digest         0.6.25     2020-02-23 [3] CRAN (R 3.6.1)                   
##  dplyr        * 0.8.5      2020-03-07 [3] CRAN (R 3.6.1)                   
##  e1071          1.7-3      2019-11-26 [3] CRAN (R 3.6.1)                   
##  ellipsis       0.3.0      2019-09-20 [3] CRAN (R 3.6.1)                   
##  evaluate       0.14       2019-05-28 [3] CRAN (R 3.6.1)                   
##  fansi          0.4.1      2020-01-08 [3] CRAN (R 3.6.1)                   
##  farver         2.0.3      2020-01-16 [3] CRAN (R 3.6.1)                   
##  fitdistrplus   1.0-14     2019-01-23 [3] CRAN (R 3.6.1)                   
##  fs             1.4.1      2020-04-04 [3] CRAN (R 3.6.3)                   
##  geosphere      1.5-10     2019-05-26 [3] CRAN (R 3.6.1)                   
##  ggplot2      * 3.3.0      2020-03-05 [3] CRAN (R 3.6.1)                   
##  glue           1.4.0      2020-04-03 [3] CRAN (R 3.6.3)                   
##  Gmedian        1.2.5      2020-03-02 [3] CRAN (R 3.6.1)                   
##  gtable         0.3.0      2019-03-25 [3] CRAN (R 3.6.1)                   
##  htmltools      0.4.0      2019-10-04 [3] CRAN (R 3.6.1)                   
##  httr           1.4.1      2019-08-05 [3] CRAN (R 3.6.1)                   
##  KernSmooth     2.23-15    2015-06-29 [6] CRAN (R 3.5.0)                   
##  knitr        * 1.28       2020-02-06 [3] CRAN (R 3.6.3)                   
##  labeling       0.3        2014-08-23 [3] CRAN (R 3.6.1)                   
##  lattice        0.20-40    2020-02-19 [6] CRAN (R 3.6.2)                   
##  lazyeval       0.2.2      2019-03-15 [3] CRAN (R 3.6.1)                   
##  lifecycle      0.2.0      2020-03-06 [3] CRAN (R 3.6.1)                   
##  lsei           1.2-0      2017-10-23 [3] CRAN (R 3.6.1)                   
##  lubridate    * 1.7.4      2018-04-11 [3] CRAN (R 3.6.1)                   
##  magrittr       1.5        2014-11-22 [3] CRAN (R 3.6.1)                   
##  MASS           7.3-51.5   2019-12-20 [6] CRAN (R 3.6.2)                   
##  Matrix         1.2-17     2019-03-22 [6] CRAN (R 3.6.1)                   
##  memoise        1.1.0      2017-04-21 [3] CRAN (R 3.6.1)                   
##  move           3.2.2      2019-09-07 [3] CRAN (R 3.6.1)                   
##  munsell        0.5.0      2018-06-12 [3] CRAN (R 3.6.1)                   
##  mvtnorm        1.1-0      2020-02-24 [3] CRAN (R 3.6.1)                   
##  npsurv         0.4-0      2017-10-14 [3] CRAN (R 3.6.1)                   
##  pillar         1.4.3      2019-12-20 [3] CRAN (R 3.6.1)                   
##  pkgbuild       1.0.6      2019-10-09 [3] CRAN (R 3.6.1)                   
##  pkgconfig      2.0.3      2019-09-22 [3] CRAN (R 3.6.1)                   
##  pkgload        1.0.2      2018-10-29 [3] CRAN (R 3.6.1)                   
##  prettyunits    1.1.1      2020-01-24 [3] CRAN (R 3.6.1)                   
##  processx       3.4.2      2020-02-09 [3] CRAN (R 3.6.1)                   
##  ps             1.3.2      2020-02-13 [3] CRAN (R 3.6.1)                   
##  purrr          0.3.4      2020-04-17 [3] CRAN (R 3.6.3)                   
##  R6             2.4.1      2019-11-12 [3] CRAN (R 3.6.1)                   
##  raster       * 3.0-12     2020-01-30 [3] CRAN (R 3.6.1)                   
##  Rcpp           1.0.4.6    2020-04-09 [3] CRAN (R 3.6.3)                   
##  remotes        2.1.1      2020-02-15 [3] CRAN (R 3.6.3)                   
##  rgdal          1.4-8      2019-11-27 [3] CRAN (R 3.6.3)                   
##  rlang          0.4.5      2020-03-01 [3] CRAN (R 3.6.1)                   
##  rmarkdown      2.0        2019-12-12 [3] CRAN (R 3.6.1)                   
##  robustbase     0.93-6     2020-03-23 [3] CRAN (R 3.6.3)                   
##  rprojroot      1.3-2      2018-01-03 [3] CRAN (R 3.6.1)                   
##  RSpectra       0.16-0     2019-12-01 [3] CRAN (R 3.6.1)                   
##  scales         1.1.0      2019-11-18 [3] CRAN (R 3.6.1)                   
##  sessioninfo    1.1.1      2018-11-05 [3] CRAN (R 3.6.1)                   
##  sf             0.9-0      2020-03-24 [3] CRAN (R 3.6.3)                   
##  sp           * 1.4-1      2020-02-28 [3] CRAN (R 3.6.3)                   
##  stringi        1.4.6      2020-02-17 [3] CRAN (R 3.6.1)                   
##  stringr        1.4.0      2019-02-10 [3] CRAN (R 3.6.1)                   
##  survival       3.1-8      2019-12-03 [3] CRAN (R 3.6.1)                   
##  testthat       2.3.2      2020-03-02 [3] CRAN (R 3.6.1)                   
##  tibble         3.0.1.9000 2020-04-23 [3] Github (tidyverse/tibble@3892a7f)
##  tidyr          1.0.2      2020-01-24 [3] CRAN (R 3.6.1)                   
##  tidyselect     1.0.0      2020-01-27 [3] CRAN (R 3.6.1)                   
##  units          0.6-6      2020-03-16 [3] CRAN (R 3.6.1)                   
##  usethis        1.6.0      2020-04-09 [3] CRAN (R 3.6.3)                   
##  utf8           1.1.4      2018-05-24 [3] CRAN (R 3.6.1)                   
##  vctrs          0.2.4      2020-03-10 [3] CRAN (R 3.6.1)                   
##  withr          2.2.0      2020-04-20 [3] CRAN (R 3.6.3)                   
##  xfun           0.13       2020-04-13 [3] CRAN (R 3.6.3)                   
##  xml2           1.3.1      2020-04-09 [3] CRAN (R 3.6.3)                   
##  yaml           2.2.1      2020-02-01 [3] CRAN (R 3.6.3)                   
## 
## [1] /tmp/Rtmp3TuR3g/Rinst55c47601aee6
## [2] /tmp/Rtmp8ySvX2/temp_libpath434e213f5de
## [3] /home/jsigner/R/x86_64-pc-linux-gnu-library/3.6
## [4] /usr/local/lib/R/site-library
## [5] /usr/lib/R/site-library
## [6] /usr/lib/R/library