Closed MarBio8 closed 5 years ago
You can use the getTrack
function to export the predicted track to a data.frame
.
Taking the included subadult_ringed_seal
as an example, after the model is fitted, e.g.:
library(argosTrack)
data(subadult_ringed_seal)
obs <- Observation(lat = subadult_ringed_seal$lat,
lon = subadult_ringed_seal$lon,
dates = as.POSIXct(subadult_ringed_seal$date),
locationclass = subadult_ringed_seal$lc)
mov <- CTCRW(unique(as.POSIXct(subadult_ringed_seal$date)))
meas <- Measurement("n")
anim <- Animal(obs,mov,meas)
fitTrack(anim)
you can use getTrack(obs)
to get a data.frame
of the observations,
head(getTrack(obs))
dates obs.lat obs.lon obs.lc
1 2010-10-20 01:31:57 56.526 -79.261 B
2 2010-10-20 02:13:06 56.583 -79.174 1
3 2010-10-20 03:12:42 56.630 -79.178 A
4 2010-10-20 03:54:43 56.638 -79.228 1
5 2010-10-20 06:03:39 56.616 -79.126 A
6 2010-10-20 07:23:00 56.646 -79.094 B
getTrack(mov)
to get a data.frame
of the predicted track,
head(getTrack(mov))
dates est.lat est.lon sd.lat sd.lon
1 2010-10-20 01:31:57 56.54845 -79.13683 0.2757000 0.2609404
2 2010-10-20 02:13:06 56.58365 -79.17754 0.3466529 0.3064188
3 2010-10-20 03:12:42 56.61960 -79.21031 0.2836951 0.2717013
4 2010-10-20 03:54:43 56.63608 -79.21785 0.2810610 0.2664699
5 2010-10-20 06:03:39 56.65861 -79.17205 0.2771995 0.2626116
6 2010-10-20 07:23:00 56.67328 -79.13332 0.2762312 0.2615650
and getTrack(anim)
to get a combined data.frame
,
head(getTrack(anim))
dates id obs.lat obs.lon obs.lc est.lat est.lon sd.lat
1 2010-10-20 01:31:57 56.526 -79.261 B 56.54845 -79.13683 0.2757000
2 2010-10-20 02:13:06 56.583 -79.174 1 56.58365 -79.17754 0.3466529
3 2010-10-20 03:12:42 56.630 -79.178 A 56.61960 -79.21031 0.2836951
4 2010-10-20 03:54:43 56.638 -79.228 1 56.63608 -79.21785 0.2810610
5 2010-10-20 06:03:39 56.616 -79.126 A 56.65861 -79.17205 0.2771995
6 2010-10-20 07:23:00 56.646 -79.094 B 56.67328 -79.13332 0.2762312
sd.lon
1 0.2609404
2 0.3064188
3 0.2717013
4 0.2664699
5 0.2626116
6 0.2615650
You can export to CSV by using the build in R function write.csv
, e.g.:
write.csv(getTrack(anim), file = "argosTrack_result.csv")
Finally, you can add standard errors on the predicted track on longitude and latitude plots by setting sd=TRUE
. For instance:
plotLat(mov, sd = TRUE)
Hi Christoffer,
Is there a way that I can export the model output (i.e., the predicted animal track) to a data.frame or spatial data.frame in R so I can use it in other packages (e.g., momentuHMM) to run behavioral predictions and use covariates (e.g., SST, currents, distance to nesting beach, etc.)? Also, I would like to be able to export to a TXT or CSV file so I could import into ArcGIS.
Is it also possible to have the SD or SE of the model predictions plotted with the latitude and longitude plots so I can assess the fit of the model to the original data?
I'm still newish to R, so forgive me if any of these questions are relatively simple.
Thanks in advance for the help!