find_stops: Find Stops

Description Usage Arguments Value Details Examples

View source: R/find_stops.R

Description

Find stops made in a route given coordinates and timestamps from a GPS track.

Usage

1
2
find_stops(.data, stop_min_duration_s = 10, digits = 3, k = 3,
  .vars = c(time = "datetime", lat = "latitude", lon = "longitude"))

Arguments

.data

(data.frame) GPS dataset.

stop_min_duration_s

(integer) Minimum stop duration cutoff in seconds. (Must be greater than k. Default: 10)

digits

(integer) Decimal places used for rounding. (Must be 0 or greater. Default: 3)

k

(integer) Window length for rolling median. (Must be odd, 3 or greater. Default: 3)

.vars

(named character vector) The datetime, latitude, and longitude variables to be found within .data. (Default: c(time = 'datetime', lat = 'latitude', lon = 'longitude'))

Value

(tibble) The coordinates and timestamps of the identified stops, along with the stop durations (integer), will be returned as a tibble.

Details

Stops are determined by finding sequential observations near the same location. A rounded rolling median is used for latitude and longitude with rle() to reduce noise. For this purpose, rounding is to digits decimal places. The stop duration cutoff stop_min_duration_s is in seconds, assuming one observation per second. Otherwise, consider this as the minimum number of observations per stop.

The GPS dataset can be a data.frame, tibble, data.table, etc., or any other object of class data.frame or that inherits from class data.drame. It must include the variables named in ".vars" which are "datetime" (datetime), "latitude" (numeric), and "longitude" (numeric) by default. If the variables are present within ".data", they will be converted to the expected data types before stop detection is performed.

Examples

1
2
3
4
5
6
## Not run: 
library(readr)
df <- read_csv(system.file("extdata", "test_data.csv", package = "stopr"))
find_stops(df)

## End(Not run)

brianhigh/stopr documentation built on Nov. 11, 2019, 6:29 a.m.