Learn R Programming

gtfs2gps (version 1.4-0)

gps_as_sfpoints: Convert GPS-like data.table to a Simple Feature points object

Description

Convert a GPS data stored in a data.table into Simple Feature points.

Usage

gps_as_sfpoints(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 point data.

Examples

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

fortaleza <- read_gtfs(system.file("extdata/fortaleza.zip", package = "gtfs2gps"))
srtmfile <- system.file("extdata/fortaleza-srtm.tif", package="gtfs2gps")

subset <- fortaleza %>%
  filter_week_days() %>%
  filter_single_trip() %>%
  filter_by_shape_id(c("shape804-I", "shape806-I"))

for_gps <- gtfs2gps(subset)
for_gps_sf_points <- gps_as_sfpoints(for_gps) # without height

for_gps <- append_height(for_gps, srtmfile)
for_gps_sf_points <- gps_as_sfpoints(for_gps) # with height
# }

Run the code above in your browser using DataLab