stopdetection

Stop Detection Algorithm for trajectory data

https://github.com/daniellemccool/stopdetection

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 4 DOI reference(s) in README
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.5%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Stop Detection Algorithm for trajectory data

Basic Info
  • Host: GitHub
  • Owner: daniellemccool
  • License: gpl-3.0
  • Language: R
  • Default Branch: main
  • Size: 317 KB
Statistics
  • Stars: 2
  • Watchers: 2
  • Forks: 1
  • Open Issues: 0
  • Releases: 0
Created over 3 years ago · Last pushed about 3 years ago

https://github.com/daniellemccool/stopdetection/blob/main/



# stopdetection




This package implements the stop detection algorithm as outlined in Ye
et al. (2009). This package provides a set of tools to cluster
timestamped movement trajectories into sets of stops (or stay points)
and tracks (or trajectories). Time-adjacent clusters are formed by first
identifying stops on the basis of provided dwell time and radius
parameters. A stop is created if all subsequent locations are within a
certain distance of an initiating location for at least as long as the
dwell time. For example, 200 meters and 5 minutes may be used in order
to find all clusters within the trajectory for which a person remained
within a circle with radius 200 meters for at least five minutes.

It is recommended to merge stops following the initial stop
identification, as documented in Montoliu, Blom, and Gatica-Perez
(2013). Merging stops requires a parameter for the maximum distance away
from each other that two stops may be while being considered the same
stop. Single points between two stops adjacent in time are removed
during this step. In data where locations are measured without error,
this step is optional. Where locations are generated with error, this
step provides an error correcting mechanism for erroneous and
low-accuracy locations.

## Installation

You can install the development version of stopdetection from
[GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("daniellemccool/stopdetection")
```

## Example

The following demonstrates the stopFinder algorithm with a distance
radius parameter of 200 meters, and a minimum time parameter of 200
seconds.

``` r
library(data.table)
library(stopdetection)
data("loc_data_2019")
setDT(loc_data_2019)
stopFinder(loc_data_2019, thetaD = 200, thetaT = 200)
```

## Extract states

Use to quickly extract a data.table containing information about the
stops and tracks

``` r
returnStateEvents(loc_data_2019)
#>      state_id   state  meanlat  meanlon          begin_time            end_time
#>                                               
#>   1:        1 stopped 52.07212 5.123761 2019-11-01 00:02:46 2019-11-01 08:05:39
#>   2:        2  moving       NA       NA 2019-11-01 08:05:55 2019-11-01 08:06:27
#>   3:        3 stopped 52.07788 5.122714 2019-11-01 08:06:42 2019-11-01 08:11:29
#>   4:        4  moving       NA       NA 2019-11-01 08:12:00 2019-11-01 08:15:24
#>   5:        5 stopped 52.08902 5.109717 2019-11-01 08:15:40 2019-11-01 08:24:10
#>  ---                                                                           
#> 323:      323  moving       NA       NA 2019-11-14 19:02:43 2019-11-14 19:11:46
#> 324:      324 stopped 52.08177 5.138043 2019-11-14 19:12:02 2019-11-14 19:57:11
#> 325:      325 stopped 52.08252 5.134228 2019-11-14 19:57:40 2019-11-14 20:01:05
#> 326:      326  moving       NA       NA 2019-11-14 20:01:20 2019-11-14 20:08:32
#> 327:      327 stopped 52.07213 5.123719 2019-11-14 20:08:47 2019-11-14 23:59:23
#>      raw_travel_dist stop_id move_id n_locations
#>                             
#>   1:              NA       1      NA         471
#>   2:        158.2833      NA       1           2
#>   3:              NA       2      NA          21
#>   4:       1253.8918      NA       2          13
#>   5:              NA       3      NA          36
#>  ---                                            
#> 323:       2171.3438      NA     110          33
#> 324:              NA     214      NA          65
#> 325:              NA     215      NA          12
#> 326:       1589.1137      NA     111          26
#> 327:              NA     216      NA         205
```

## Merge stops/handle short tracks

Subsequent nearby stops can be merged based on the distance of their
centroids. This is often useful if they represent the same stop
subjectively. Short tracks can be either merged into the previous stop
or excluded. Often short tracks represent erroneously measured GNSS
locations of one or two points, so excluding them is helpful. The
combination of excluding short tracks and merging stops can be used to
handle noisy location data.

``` r
mergingCycle(loc_data_2019, thetaD = 200, small_track_action = "exclude", max_locs = Inf, max_dist = 200)
returnStateEvents(loc_data_2019)
#>      state_id    state  meanlat  meanlon          begin_time
#>                                  
#>   1:        1  stopped 52.07212 5.123760 2019-11-01 00:02:46
#>   2:       NA excluded       NA       NA 2019-11-01 08:05:55
#>   3:        2  stopped 52.07785 5.122780 2019-11-01 08:06:42
#>   4:        3   moving       NA       NA 2019-11-01 08:12:00
#>   5:        4  stopped 52.08902 5.109717 2019-11-01 08:15:40
#>  ---                                                        
#> 251:      250   moving       NA       NA 2019-11-14 19:02:43
#> 252:      251  stopped 52.08177 5.138043 2019-11-14 19:12:02
#> 253:      252  stopped 52.08252 5.134228 2019-11-14 19:57:40
#> 254:      253   moving       NA       NA 2019-11-14 20:01:20
#> 255:      254  stopped 52.07213 5.123719 2019-11-14 20:08:47
#>                 end_time raw_travel_dist stop_id move_id n_locations
#>                                           
#>   1: 2019-11-01 08:05:39              NA       1      NA         471
#>   2: 2019-11-14 16:44:47              NA      NA      NA          68
#>   3: 2019-11-01 08:11:29              NA       2      NA          21
#>   4: 2019-11-01 08:15:24        1253.892      NA       1          13
#>   5: 2019-11-01 08:24:10              NA       3      NA          36
#>  ---                                                                
#> 251: 2019-11-14 19:11:46        2171.344      NA      77          33
#> 252: 2019-11-14 19:57:11              NA     174      NA          65
#> 253: 2019-11-14 20:01:05              NA     175      NA          12
#> 254: 2019-11-14 20:08:32        1589.114      NA      78          26
#> 255: 2019-11-14 23:59:23              NA     176      NA         205
```

# References

Montoliu, Raul, Jan Blom, and Daniel Gatica-Perez. 2013. Discovering Places of Interest in Everyday Life from Smartphone Data. *Multimedia Tools and Applications* 62 (1): 179207. .
Ye, Yang, Yu Zheng, Yukun Chen, Jianhua Feng, and Xing Xie. 2009. Mining Individual Life Pattern Based on Location History. In *Proceedings of the 2009 Tenth International Conference on Mobile Data Management: Systems, Services and Middleware*, 110. MDM 09. USA: IEEE Computer Society. .

Owner

  • Name: Danielle McCool
  • Login: daniellemccool
  • Kind: user
  • Location: Utrecht, Netherlands
  • Company: University of Utrecht

Postdoc researcher interested in smart surveys, missing data, and spatial statistics

GitHub Events

Total
Last Year

Issues and Pull Requests

Last synced: over 1 year ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 207 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 3
  • Total maintainers: 1
cran.r-project.org: stopdetection

Stop Detection in Timestamped Trajectory Data using Spatiotemporal Clustering

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 207 Last month
Rankings
Dependent packages count: 29.8%
Dependent repos count: 35.5%
Average: 41.2%
Downloads: 58.4%
Maintainers (1)
Last synced: over 1 year ago

Dependencies

DESCRIPTION cran
  • R >= 2.10 depends
  • data.table * imports
  • geodist * imports
  • lubridate * imports
  • stats * imports
  • knitr * suggests
  • rmarkdown * suggests
  • testthat >= 3.0.0 suggests