Reading files downloaded from movebank
mt_read(file, ...)
An object of the class move2
The file path to read or a R connection (for details see connections
).
Files can either be csv files from movebank or zip files that are created using Env-DATA.
Arguments passed on to vroom
, for example col_select
Files can be gz
compressed and if the same columns are present multiple files can be read simultaneously.
Using the pipe command in R and some command line tools it is possible to select specific days or months.
When using the col_select
argument of vroom
it is possible to speed up file reading
considerably while reducing memory consumption.
Especially columns containing acceleration values can become quite large.
For files that contain both a individual-local-identifier
and a tag-local-identifier
column a
check is preformed if individuals have been wearing multiple tags over time. If this is the case tracks are
created based on the combination of both id's. A new column names individual-tag-local-identifier
in created,
which will correspond to the track ids. This somewhat resembles the movebank logic however the track ids do
not necessarily correspond to the deployments in movebank as this information is not contained in exported csv's.
mt_example()
for the path to an example file.
path_fishers <- mt_example()
mt_read(path_fishers)
## Reduce the mount of data read this might provide memory advantages
## and speed up reading
mt_read(path_fishers, col_select = c(
"location-long", "location-lat",
"timestamp", "individual-local-identifier"
))
## Read Galapagos Albatross data that has been annotated
mt_read(mt_example("Galapagos_Albatrosses-1332012225316982996.zip"))
## Notice this produces a warning as some units are not recognized
## This can be prevented by installing the units
if (FALSE) {
units::install_unit("gC", "g", "Grams of carbon")
}
if (FALSE) {
## Reading can also be manipulted to speed up or reduce memory consumption
## Here we assume the Galapagos albatross data has been downloaded
mt_read("~/Downloads/Galapagos Albatrosses.csv")
## Exclude the column 'eobs:accelerations-raw'
mt_read("~/Downloads/Galapagos Albatrosses.csv",
col_select = (!`eobs:accelerations-raw`)
)
## Only read records from July 2008 using a system pipe where the data
## is already filtered before reading into R
mt_read(pipe('cat "~/Downloads/Galapagos Albatrosses.csv" | grep "2008-07\\|time"'))
}
Run the code above in your browser using DataLab