MyNixOS website logo
Description

Top-Down Time Ratio Segmentation for Coordinate Trajectories.

Data collected on movement behavior is often in the form of time- stamped latitude/longitude coordinates sampled from the underlying movement behavior. These data can be compressed into a set of segments via the Top- Down Time Ratio Segmentation method described in Meratnia and de By (2004) <doi:10.1007/978-3-540-24741-8_44> which, with some loss of information, can both reduce the size of the data as well as provide corrective smoothing mechanisms to help reduce the impact of measurement error. This is an improvement on the well-known Douglas-Peucker algorithm for segmentation that operates not on the basis of perpendicular distances. Top-Down Time Ratio segmentation allows for disparate sampling time intervals by calculating the distance between locations and segments with respect to time. Provided a trajectory with timestamps, tdtr() returns a set of straight- line segments that can represent the full trajectory. McCool, Lugtig, and Schouten (2022) <doi:10.1007/s11116-022-10328-2> describe this method as implemented here in more detail.

topdowntimeratio

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 Meratnia and By (2004), and as implemented in McCool, Lugtig, and Schouten (2022).

Installation

When it’s released (it isn’t yet), you can install the released version of topdowntimeratio from CRAN with:

install.packages("topdowntimeratio")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("daniellemccool/topdowntimeratio")

Example

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)
#>    entity_id  lon   lat timestamp timestamp_numeric segment_start segment_end
#> 1:         1 5.00 32.01       500               500          TRUE       FALSE
#> 2:         1 5.01 32.04       600               600         FALSE       FALSE
#> 3:         1 5.02 32.06       800               800         FALSE       FALSE
#> 4:         1 5.05 32.10      2000              2000         FALSE        TRUE
#>    adjusted_lat adjusted_lon segment_id seg_start_lat seg_start_lon
#> 1:       32.010     5.000000          1         32.01             5
#> 2:       32.016     5.003333          1         32.01             5
#> 3:       32.028     5.010000          1         32.01             5
#> 4:       32.100     5.050000          1         32.01             5
#>    seg_start_time seg_end_lat seg_end_lon seg_end_time seg_dur seg_dist_lat
#> 1:            500        32.1        5.05         2000    1500         0.09
#> 2:            500        32.1        5.05         2000    1500         0.09
#> 3:            500        32.1        5.05         2000    1500         0.09
#> 4:            500        32.1        5.05         2000    1500         0.09
#>    seg_dist_lon perc_of_seg_dur     dist
#> 1:         0.05      0.00000000    0.000
#> 2:         0.05      0.06666667 2744.752
#> 3:         0.05      0.20000000 3685.078
#> 4:         0.05      1.00000000    0.000

Plot example, initial segment

Plot example, new segment at greatest distance

McCool, Danielle, Peter Lugtig, and Barry Schouten. 2022. “Maximum Interpolable Gap Length in Missing Smartphone-Based GPS Mobility Data.” Transportation. https://doi.org/10.1007/s11116-022-10328-2.

Meratnia, Nirvana, and Rolf A de By. 2004. “Spatiotemporal Compression Techniques for Moving Point Objects.” In Advances in Database Technology - EDBT 2004, 765–82. Springer Berlin Heidelberg. https://doi.org/10.1007/978-3-540-24741-8\_44.

Metadata

Version

0.1.0

License

Unknown

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows