{"action":"created","issue":{"url":"https://api.github.com/repos/ctmm-initiative/ctmm/issues/28","repository_url":"https://api.github.com/repos/ctmm-initiative/ctmm","labels_url":"https://api.github.com/repos/ctmm-initiative/ctmm/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/ctmm-initiative/ctmm/issues/28/comments","events_url":"https://api.github.com/repos/ctmm-initiative/ctmm/issues/28/events","html_url":"https://github.com/ctmm-initiative/ctmm/issues/28","id":369774447,"node_id":"MDU6SXNzdWUzNjk3NzQ0NDc=","number":28,"title":"`ctmm::simulate`, how to backtransform coordinates?","user":{"login":"jmsigner","id":813059,"node_id":"MDQ6VXNlcjgxMzA1OQ==","avatar_url":"https://avatars1.githubusercontent.com/u/813059?v=4","gravatar_id":"","url":"https://api.github.com/users/jmsigner","html_url":"https://github.com/jmsigner","followers_url":"https://api.github.com/users/jmsigner/followers","following_url":"https://api.github.com/users/jmsigner/following{/other_user}","gists_url":"https://api.github.com/users/jmsigner/gists{/gist_id}","starred_url":"https://api.github.com/users/jmsigner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmsigner/subscriptions","organizations_url":"https://api.github.com/users/jmsigner/orgs","repos_url":"https://api.github.com/users/jmsigner/repos","events_url":"https://api.github.com/users/jmsigner/events{/privacy}","received_events_url":"https://api.github.com/users/jmsigner/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-10-13T06:55:00Z","updated_at":"2018-10-13T19:02:49Z","closed_at":null,"author_association":"NONE","body":"I am having some troubles understanding how to back transform coordinates to the original coordinates system after simulating a path. I tried to illustrate the problem with a small repex (below).\r\n\r\nAny hints or pointers to what I am doing wrong would be greatly be appreciated. \r\n\r\n```\r\nlibrary(lubridate)\r\nlibrary(move)\r\nlibrary(ctmm)\r\n\r\nset.seed(123)\r\n\r\n# Generate some dummy data\r\ndat <- data.frame(x = cumsum(rnorm(100)),\r\n                  y = cumsum(rnorm(100)),\r\n                  t = ymd(\"2018-01-01\") + hours(0:99))\r\n\r\n# Create a telemetry object via move\r\nm <- move(x = dat$x, y = dat$y,\r\n                time = dat$t, proj = sp::CRS(\"+init=epsg:4326\"),\r\n                data = data.frame(individual.local.identifier = rep(\"1\", nrow(dat))))\r\n\r\nc1 <- as.telemetry(m)\r\n\r\n# Fit a ou model\r\ng <- ctmm.guess(c1, interactive = FALSE)\r\nou <- ctmm.fit(c1, ctmm(tau = g$tau[1]))\r\n\r\n# Simulate from this model\r\nt <- as.numeric(dat$t)\r\ns1 <- simulate(ou, data = c1, t = t)\r\n\r\n# Coordinates are very differnt\r\nplot(s1)\r\n\r\n# from\r\nplot(dat[, 1:2])\r\n\r\n# Coerce to spatial points doesent help\r\np1 <- SpatialPointsDataFrame(s1)\r\nsp::plot(p1, axes = TRUE)\r\n\r\n# from\r\nplot(dat[, 1:2])\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/ctmm-initiative/ctmm/issues/comments/429567014","html_url":"https://github.com/ctmm-initiative/ctmm/issues/28#issuecomment-429567014","issue_url":"https://api.github.com/repos/ctmm-initiative/ctmm/issues/28","id":429567014,"node_id":"MDEyOklzc3VlQ29tbWVudDQyOTU2NzAxNA==","user":{"login":"jmsigner","id":813059,"node_id":"MDQ6VXNlcjgxMzA1OQ==","avatar_url":"https://avatars1.githubusercontent.com/u/813059?v=4","gravatar_id":"","url":"https://api.github.com/users/jmsigner","html_url":"https://github.com/jmsigner","followers_url":"https://api.github.com/users/jmsigner/followers","following_url":"https://api.github.com/users/jmsigner/following{/other_user}","gists_url":"https://api.github.com/users/jmsigner/gists{/gist_id}","starred_url":"https://api.github.com/users/jmsigner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmsigner/subscriptions","organizations_url":"https://api.github.com/users/jmsigner/orgs","repos_url":"https://api.github.com/users/jmsigner/repos","events_url":"https://api.github.com/users/jmsigner/events{/privacy}","received_events_url":"https://api.github.com/users/jmsigner/received_events","type":"User","site_admin":false},"created_at":"2018-10-13T19:02:49Z","updated_at":"2018-10-13T19:02:49Z","author_association":"NONE","body":"If you use `sp::spTransform` the the CRS is actually transformed not just overwritten (as it is the case with `projection`). \r\n\r\nIt works well, if I omit the move package and use 'relatively small' coord values. \r\n\r\n```\r\nlibrary(ctmm)\r\nset.seed(123)\r\n\r\n# Generate some dummy data: works well\r\ndat <- data.frame(lon = cumsum(rnorm(100)),\r\n                  lat = cumsum(rnorm(100)),\r\n                  timestamp = ymd(\"2018-01-01\") + hours(0:99))\r\n\r\nxx <- as.telemetry(dat)\r\nslot(xx, \".Data\")\r\n\r\n# Generate some dummy data: coords are Inf, which causes troubles later\r\n# I assume as.telemetry expects geographical coordinates\r\ndat <- data.frame(lon = 1e3 + cumsum(rnorm(100)),\r\n                  lat = 1e3 + cumsum(rnorm(100)),\r\n                  timestamp = ymd(\"2018-01-01\") + hours(0:99))\r\n\r\nxx <- as.telemetry(dat)\r\nslot(xx, \".Data\")\r\n\r\n# Generate some dummy data: coords are Inf, which causes troubles later \r\n# But even if I provide a different CRS, it appears not be recognized.\r\ns <- SpatialPoints(cbind(10, 52), CRS(\"+init=epsg:4326\"))\r\ns <- coordinates(spTransform(s, CRS(\"+init=epsg:3035\")))\r\ndat <- data.frame(lon = s[1, 1] + cumsum(rnorm(100)),\r\n                  lat = s[1, 2] + cumsum(rnorm(100)),\r\n                  timestamp = ymd(\"2018-01-01\") + hours(0:99))\r\n\r\nxx <- as.telemetry(dat, projection = CRS(\"+init=epsg:3035\"))\r\nslot(xx, \".Data\")\r\n```\r\n\r\n\r\n"}}
{"actor":{"display_login":"jmsigner"}}