jmsigner / amt

37 stars 13 forks source link

Updating crs argument in mk_track to accept WKT2 string #35

Closed WhitneyH1317 closed 2 years ago

WhitneyH1317 commented 3 years ago

Currently the crs argument in the mk_track function only accepts proj4string characters, when R has now moved on to WKT2 strings. Attempting hr_akde from a track_xyt object with a deprecated CRS argument in a newly updated R environment no longer works.

jmsigner commented 2 years ago

Sorry for the long delay. This should all work since a few updates already.

library(amt)
mini_deer <- deer[1:100, ]
get_crs(mini_deer)

# Data without CRS
dat <- data.frame(x = mini_deer$x_, y = mini_deer$y_, t = mini_deer$t_)
dat <- make_track(dat, x, y, t)
get_crs(dat)
hr_akde(dat) # Error as expected

# Use deprecated proj4string
dat <- data.frame(x = mini_deer$x_, y = mini_deer$y_, t = mini_deer$t_)
dat <- make_track(dat, x, y, t, crs = CRS("+init=epsg:3035"))
get_crs(dat)
hr_akde(dat) # Works fine

# Using new WKT2
dat <- data.frame(x = mini_deer$x_, y = mini_deer$y_, t = mini_deer$t_)
dat <- make_track(dat, x, y, t, crs = 3035)
get_crs(dat)
hr_akde(dat) # Works fine