knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of topdowntimeratio is to condense sequences of longitudinal GPS data into segments for ease of processing. This package was developed based on the method outlined in @Meratnia2004-mv, and as implemented in @McCool2022-yo.
The released version of topdowntimeratio can be installed from CRAN with:
install.packages("topdowntimeratio")
And the development version from GitHub with:
# install.packages("devtools") devtools::install_github("daniellemccool/topdowntimeratio")
Basic usage requires that your data has at least longitude and latitude coordinates as well as a timestamp and an id column. You can provide the names if they differ from entity_id, lon, lat and timestamp.
Here we generate a single segment
library(topdowntimeratio) df <- data.frame(entity_id = c(1, 1, 1, 1), lon = c(5, 5.01, 5.02, 5.05), lat = c(32.01, 32.04, 32.06, 32.10), timestamp = c(500, 600, 800, 2000)) res <- tdtr(df, n_segs = 1, group_col = NULL) print(res)
Plot example, initial segment
plot(res$lon, res$lat) segments(res$seg_start_lon, res$seg_start_lat, res$seg_end_lon, res$seg_end_lat)
Plot example, new segment at greatest distance
res <- tdtr(df, n_segs = 2, group_col = NULL) plot(res$lon, res$lat) segments(res$seg_start_lon, res$seg_start_lat, res$seg_end_lon, res$seg_end_lat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.