convert_sf_to_shapes {gtfstools} | R Documentation |
Convert a simple feature object into a shapes
table
Description
Converts a LINESTRING sf
object into a GTFS shapes
table.
Usage
convert_sf_to_shapes(sf_shapes, shape_id = NULL, calculate_distance = TRUE)
Arguments
sf_shapes |
A |
shape_id |
A character vector specifying the |
calculate_distance |
A logical. Whether to calculate and populate the
|
Value
A data.table
representing a GTFS shapes
table.
Examples
data_path <- system.file("extdata/spo_gtfs.zip", package = "gtfstools")
gtfs <- read_gtfs(data_path)
# first converting existing shapes table into a sf object
shapes_sf <- convert_shapes_to_sf(gtfs)
head(shapes_sf)
# by default converts all shapes
result <- convert_sf_to_shapes(shapes_sf)
result
# shape_id argument controls which shapes are converted
result <- convert_sf_to_shapes(shapes_sf, shape_id = c("17846", "17847"))
result
# calculate_distance argument controls whether to calculate
# shape_dist_traveled or not
result <- convert_sf_to_shapes(shapes_sf, calculate_distance = TRUE)
result
[Package gtfstools version 1.4.0 Index]