Learn R Programming

gtfs2gps (version 1.4-0)

gps_as_sflinestring: Converts a GPS-like data.table to a LineString Simple Feature (sf) object

Description

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.

Usage

gps_as_sflinestring(gps, crs = 4326)

Arguments

gps

A data.table with timestamp data.

crs

A Coordinate Reference System. The default value is 4326 (latlong WGS84).

Value

A simple feature (sf) object with LineString data.

Examples

Run this code
# NOT RUN {
library(gtfs2gps)
library(dplyr)

poa <- read_gtfs(system.file("extdata/poa.zip", package = "gtfs2gps"))
poa_subset <- filter_by_shape_id(poa, c("T2-1", "A141-1")) %>%
  filter_single_trip()

poa_gps <- gtfs2gps(poa_subset)

poa_gps_sf <- gps_as_sflinestring(poa_gps)
# }

Run the code above in your browser using DataLab