R/gps_as_sfpoints.R
gps_as_sfpoints.Rd
Convert a GPS data stored in a data.table into Simple Feature points.
gps_as_sfpoints(gps, crs = 4326)
A data.table with timestamp data.
A Coordinate Reference System. The default value is 4326 (latlong WGS84).
A simple feature (sf) object with point data.
library(gtfs2gps)
library(magrittr)
fortaleza <- read_gtfs(system.file("extdata/fortaleza.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
srtmfile <- system.file("extdata/fortaleza-srtm.tif", package="gtfs2gps")
subset <- fortaleza %>%
gtfstools::filter_by_weekday(c("monday", "wednesday")) %>%
filter_single_trip() %>%
gtfstools::filter_by_shape_id("shape806-I")
for_gps <- gtfs2gps(subset)
#> Converting shapes to sf objects
#> Using 1 CPU cores
#> Processing the data
for_gps_sf_points <- gps_as_sfpoints(for_gps)