Estimate stop coordinates from vehicle positions
Source:R/baseline_free.R
g2g_stops_from_positions.RdBaseline-free helper: when no static GTFS feed exists, stop locations can
be estimated from GTFS-Realtime Vehicle Positions that carry a
stop_id annotation. Each stop's coordinates are the median position
of the pings observed at it — by default only pings labeled
STOPPED_AT, the most precise signal.
Arguments
- positions
A data.frame of vehicle positions (e.g. from
gtfsrealtime::read_gtfsrt_positions()org2g_clean_gps()) with columnsstop_id,latitude,longitude, and optionallycurrent_status.- statuses
Character vector of
current_statusvalues to use. Default"STOPPED_AT". Ignored (allstop_id-annotated pings used, with a message) when thecurrent_statuscolumn is absent.- min_obs
Integer. Minimum number of pings required per stop; stops with fewer observations are dropped with a warning. Default
3.
Details
The result covers the stop_id/latitude/longitude
columns of the stops_data input to
g2g_extract_trips_and_stop_times; the direction label
(starting terminal of trips serving the stop) must still be supplied, e.g.
from the RT trip_id/direction_id annotations or a baseline
feed. It also fills the spec-required stop_lat/stop_lon of a
scaffolded stops.txt.