These functions provide support reading and writing routes and intervals from and to HDF5 files while preserving class names and attributes.
Usage
write_routes(obj, path)
# S3 method for class 'Routes'
write_routes(obj, path)
# S3 method for class 'BirdFlowRoutes'
write_routes(obj, path)
# Default S3 method
write_routes(obj, path)
read_routes(path)
read_intervals(path)
write_intervals(obj, path)Value
write_routes()andwrite_intervals()invisibly return their input object (after writing to disk).read_routes()returns the written object - eitherRoutesorBirdFlowRoutes.read_intervals()return the writtenBirdFlowIntervalsobject.
Details
The Hierarchical Data Format version 5 (HDF5) is an open format to efficiently store large, heterogeneous data sets. HDF5 files can be written and read from R and Python among other languages so make a good cross-language format for routes and intervals.
read_routes() and write_routes() work on both Routes and
BirdFlowRoutes. See as_routes() and as_birdflow_routes() to create
objects of these classes.
read_intervals() and write_intervals() work on BirdFlowIntervals
which are a collection of movements each with a single start and end
derived from BirdFlowRoutes. See as_birdflow_intervals().
Internal functions
write_r_object_h5()andread_r_object_h5()are internal workhorses: they handle the recursive traversal of R lists (including data.frames, Date/POSIX/Factor vectors) and store both data and class attributes in the HDF5 file hierarchy.
See also
rhdf5::h5createFile, rhdf5::h5write, rhdf5::h5read for low-level HDF5 operations.
import_birdflow(), andexport_birdflow()for reading and writing BirdFlow models. Noteimport_birdflow()also substantially alters the object if it has not previously been imported into R.
Examples
# \donttest{
bf <- BirdFlowExamples::amewoo
rts <- route(bf, n = 3)
route_path <- tempfile(fileext = ".hdf5")
write_routes(rts, route_path)
rts2 <- read_routes(route_path)
identical(class(rts), class(rts2))
#> [1] TRUE
ivl <- as_birdflow_intervals(rts)
interval_path <- tempfile(fileext = ".hdf5")
write_intervals(ivl, interval_path)
ivl2 <- read_intervals(interval_path)
identical(class(ivl), class(ivl2))
#> [1] TRUE
# }
