View source: R/get_shape_length.R
| get_shape_length | R Documentation |
Returns the length of each specified shape_id, from its first to its last
point.
get_shape_length(gtfs, shape_id = NULL, unit = "km")
gtfs |
A GTFS object, as created by |
shape_id |
A character vector including the |
unit |
A string representing the unit in which lengths are desired.
Either |
A data.table with the shape_id and the length of each shape.
The points of each shape are sorted by shape_pt_sequence before the length
is calculated. Lengths are great-circle distances calculated with the
haversine formula, on a sphere with the same radius used by {s2}
(6,371,010 meters), regardless of whether sf::sf_use_s2() is enabled.
Shapes with any point with missing coordinates have NA lengths.
A trip usually travels only part of its shape, from its first to its last
stop. Use get_trip_length() to calculate the length of the trips.
get_trip_length()
data_path <- system.file("extdata/spo_gtfs.zip", package = "gtfstools")
gtfs <- read_gtfs(data_path)
shape_length <- get_shape_length(gtfs)
head(shape_length)
shape_length <- get_shape_length(gtfs, c("17846", "68962"), unit = "m")
shape_length
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.