| plot_interactive_gtfs | R Documentation |
This function generates a simple Leaflet-based interactive map viewer of a GTFS. This function is intended for quick and easy visualization of a GTFS feed. As such, formatting options are relatively limited.
plot_interactive_gtfs(
gtfs,
background = "Esri.WorldGrayCanvas",
color_palette = "Dark2"
)
gtfs |
A tidytransit GTFS object. |
background |
Optional. A string for the background of the transit map,
from Leaflet's provider library (see |
color_palette |
Optional. A string for the Leaflet color palette to
color routes. If |
The primary goal of this function is to visualize and explore each GTFS
shape, including its associated route_id and direction_id. This function
will plot all shapes and stops present in the input gtfs. To plot only
a specific route or direction, first filter the feed using
filter_by_route().
Routes have both pop-ups and hover labels. The hover label shows the
shapes's route_id (from the trips file). The pop-up will show the
route_id, direction_id, and shape_id.
Stops also have both pop-ups and hover labels. The hover label will show the
point's stop_id (from the stops file). The pop-up will show the
stop_name and stop_id.
Two formatting options are available through this function: basemaps and route color palettes.
The background parameter allows you to customize the background basemap.
Esri's light grey canvas is the default, as it
is excellent for providing geographic context while still allowing the
routes to stand out. To see the available options, type
leaflet::providers$ into your console.
The route colors can be customized in two different ways:
Using the gtfs's colors. Typically, the routes file in a GTFS feed
will contain a field route_color; this is the color you see in most
public-facing mapping/navigation applications (e.g., Google Maps,
Transit App, etc.). If this is present in the input gtfs feed, setting
color_palette = "gtfs" will use this field to color each shape.
Using a named color palette. Without gtfs colors, this function
assigns colors categorically (using leaflet::colorFactor()). To set
the palette, input a string corresponding to a palette name from
RColorBrewer, a palette name from viridis, a vector of color names (with
the same length as the number of shapes), or some other color function. See
Leaflet's
colors vignette
for more information.
A Leaftlet object.
plot_interactive_gtfs(gtfs = lacmta_gtfs,
color_palette = "gtfs")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.