Create an object of class
trip, extending the basic functionality
SpatialPointsDataFrame-class by specifying the data columns
that define the "TimeOrdered" quality of the records.
trip(obj, TORnames, correct_all = TRUE) trip(obj) <- value ## S4 method for signature 'trip,ANY' split(x, f, drop = FALSE, ...) ## S4 method for signature 'trip,ANY,ANY,ANY' x[i, j, ..., drop = TRUE]
A data frame, a grouped data frame or a
logical value, if
A 4-element character vector specifying the X, Y, DateTime coordinates
and ID of
grouping vector as per
unused but necessary for method consistency
indices specifying elements to extract
The original form of
trip() required very strict input as a 'SpatialPointsDataFrame' and
specifying which were the time and ID columns, but the input can be more flexible. If the object is a
grouped data frame ('dplyr-style') then the (first) grouping is assumed to define individual trips and that
columns 1, 2, 3 are the x-, y-, time-coordinates in that order. It can also be a
trip object for
trip() function can ingest
mousetrap, and in some cases
lists of those objects. Please get in touch if you think something that should work does not.
Track data often contains problems, with missing values in location or time,
times out of order or with duplicated times. The
correct_all argument is
TRUE by default and will report any inconsistencies. Data really should
be checked first rather than relying on this auto-cleanup. The following problems are common:
duplicated records (every column with the same value in another row)
duplicated date-time values
missing date-time values, or missing x or y coordinates
records out of order within trip ID
For some data types there's no formal structure, but a simple convention such as
a set of names in a data frame. For example, the VTrack package has
AATAMS1 which may be
turned into a trip with
trip(AATAMS1 %>% dplyr::select(longitude, latitude, timestamp, tag.ID, everything())
In time we can add support for all kinds of variants, detected by the names and contents.
See Chapter 2 of the trip thesis for more details.
A trip object, with the usual slots of a
SpatialPointsDataFrame-class and the added
TimeOrderedRecords. For the most part this can be treated as a
Most of the methods available are by virtue of the sp package. Some, such
split.data.frame have been added to SPDF so that trip has the same
The main construction.
Object and TimeOrdered records class
trip object from a data frame.
signature(obj="trip", TORnames="ANY"): (Re)-create a
trip object using a character vector for
(re)-create a trip object using a
tripGrid for simplistic
speed filtering and spatial time spent gridding.
d <- data.frame(x=1:10, y=rnorm(10), tms=Sys.time() + 1:10, id=gl(2, 5)) ## the simplest way to create a trip is by order of columns trip(d) tr <- trip(d) ## real world data in CSV mi_dat <- read.csv(system.file("extdata/MI_albatross_sub10.csv", package = "trip"), stringsAsFactors = FALSE) mi_dat$gmt <- as.POSIXct(mi_dat$gmt, tz = "UTC") mi_dat$sp_id <- sprintf("%s%s_%s_%s", mi_dat$species, substr(mi_dat$breeding_status, 1, 1), mi_dat$band, mi_dat$tag_ID) sp::coordinates(mi_dat) <- c("lon", "lat") ## there are many warnings, but the outcome is fine ## (sp_id == 'WAi_14030938_2123' has < 3 locations as does LMi_12143650_14257) mi_dat <- trip(mi_dat, c("gmt", "sp_id") ) plot(mi_dat, pch = ".") #lines(mi_dat) ## ugly mi_dat_polar <- reproj(mi_dat, "+proj=stere +lat_0=-90 +lon_0=154 +datum=WGS84") plot(mi_dat_polar, pch = ".") lines(mi_dat_polar)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.