R/gps_as_sflinestring.R
gps_as_sflinestring.Rd
Every interval of GPS data points between stops for each trip_id is converted into a linestring segment. The output assumes constant average speed between consecutive stops.
gps_as_sflinestring(gps)
A data.table with timestamp data.
A simple feature (sf) object with LineString data.
library(gtfs2gps)
library(magrittr)
poa <- read_gtfs(system.file("extdata/poa.zip", package = "gtfs2gps"))
#> Unzipped the following files to /tmp/Rtmp8QhZHv/gtfsio:
#> * agency.txt
#> * calendar.txt
#> * routes.txt
#> * shapes.txt
#> * stop_times.txt
#> * stops.txt
#> * trips.txt
#> Reading agency.txt
#> Reading calendar.txt
#> Reading routes.txt
#> Reading shapes.txt
#> Reading stop_times.txt
#> Reading stops.txt
#> Reading trips.txt
poa_subset <- gtfstools::filter_by_shape_id(poa, c("T2-1", "A141-1")) %>%
filter_single_trip()
poa_gps <- gtfs2gps(poa_subset)
#> Converting shapes to sf objects
#> Using 1 CPU cores
#> Processing the data
#> Some 'speed' values are NA in the returned data.
poa_gps_sf <- gps_as_sflinestring(poa_gps)