Skip to content

Link Trips

Link unlinked trip segments into complete journey records.

Detects mode changes and aggregates trip chains by validating spatial and temporal continuity across consecutive trips.

Algorithm
  1. Sort unlinked trips by person, day, and departure time
  2. For each person-day sequence:
    • If previous trip's destination purpose is change_mode_enum, continue current linked trip
    • Validate spatial/temporal continuity:
      • Time gap between trips ≤ max_dwell_time minutes
      • Distance between previous destination and current origin ≤ dwell_buffer_distance meters
      • With split_on_occupancy, the reported party size is unchanged
    • Otherwise, start a new linked trip
  3. Assign globally unique linked_trip_id: the day_id followed by a two-digit sequence number
  1. Group unlinked trips by linked_trip_id
  2. For each linked trip, aggregate:
    • Origin/Destination: First trip's origin, last trip's destination
    • Timing: First depart_time, last arrive_time
    • Distance: Sum of all trip distances
    • Duration: Sum of all trip durations (including dwell time)
    • Purposes: First origin purpose, last destination purpose
    • Mode Logic:
      • If any segment uses a transit mode → the mode of the longest-duration transit segment
      • Otherwise, the mode of the longest-duration segment
    • Transit Details: Count boarding/alighting, aggregate access/egress modes
    • Driver/Passenger: Aggregate from component trips
Notes
  • Links trips when travelers make intermediate stops for mode changes or transfers
  • Preserves full trip detail in unlinked_trips while creating journey-level linked_trips
  • Transit detection ensures multi-modal journeys classified correctly
  • Access/egress mode mapping converts trip modes to transit-specific codes
  • Spatial/temporal thresholds prevent false linkages across separate journeys

Example

Example
- name: link_trips
  params:
    change_mode_enum: CHANGE_MODE
    transit_mode_enums: [FERRY, TRANSIT, LONG_DISTANCE]
    max_dwell_time: 180         # minutes
    dwell_buffer_distance: 100  # meters
    split_on_occupancy: false

Settings

Key Type Default Meaning
change_mode_enum text required Enum label indicating a mode change purpose.
transit_mode_enums list required List of enum labels that count as transit modes.
max_dwell_time number 120 Maximum time gap between trips to link them, in minutes (default: 120).
dwell_buffer_distance number 100 Maximum spatial distance between trips to link, in meters (default: 100).
split_on_occupancy true / false required Refuse to link two segments whose reported party size differs. A change of occupancy at a stop is evidence that somebody was picked up or dropped off, which makes the stop an activity rather than a transfer. Required, and deliberately without a default: either answer changes what a linked trip is, so the choice belongs to whoever configured the run rather than to this signature.

Code: processing.link_trips