View source: R/get_route_geometry.R
| get_route_geometry | R Documentation |
Returns the distinct geometries of the trips of each specified route_id
(its "variants", e.g. each direction and each short-turn service), with the
trip_id that identifies each of them and the number of trips that follow
them.
get_route_geometry(gtfs, route_id = NULL, method = "shapes", crs = 4326)
gtfs |
A GTFS object, as created by |
route_id |
A character vector including the |
method |
A string, either |
crs |
The CRS of the resulting object, either as an EPSG code or as an
|
A LINESTRING sf with one row per route and distinct trip
geometry, with the columns route_id, trip_pattern (the first
trip_id, in alphabetical order, of the route's trips with that geometry,
which identifies it), n_trips (the number of trips of the route with
that geometry) and geometry. Rows are ordered by
route_id (with NA last) and, within each route, by decreasing
n_trips.
The geometry of each trip is generated as in get_trip_geometry(), so it
goes from the trip's first to its last stop, either along its shape or as
straight lines between its stops, and the same limitations and warnings
apply. The trips of a route whose geometries are identical are then merged
into a single row. Trips that visit stops at different points of the same
shape thus result in different rows, even if their geometries overlap.
Only trips listed both in trips and in stop_times are considered, so
routes without any trip listed in stop_times are not included in the
output. When a trip_id is listed more than once in trips, only its first
entry is considered. With route_id = NULL, trips with a missing
route_id are grouped together, under an NA route_id. Trips without
any stop with coordinates (and, with method = "shapes", trips that can't
be located along a shape) get an empty geometry, as in
get_trip_geometry(), and these trips are counted in an empty-geometry row
of their route.
get_trip_geometry(), get_shapes_geometry()
data_path <- system.file("extdata/spo_gtfs.zip", package = "gtfstools")
gtfs <- read_gtfs(data_path)
route_geometry <- get_route_geometry(gtfs)
head(route_geometry)
route_geometry <- get_route_geometry(gtfs, route_id = "CPTM L07")
route_geometry
plot(route_geometry["n_trips"])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.