Skip to content

Output format

run_pipeline returns the processed trajectories (a GeoDataFrame, one row per vehicle and grid time); run_pipeline_detailed returns them together with the lane-change event table (a PipelineResult with tracks and events). Both attach the run metadata to out.attrs["trajlab"] (read it with trajlab.run_metadata(out)). Column names are defined in trajlab/conventions.py. The method behind each column is described in method.md.

Conventions

Topic Convention
Longitudinal position pos_lon (s, m) along the reference line, increasing in the direction of travel, whatever direction the line was digitized in.
Lateral position pos_lat (d, m), positive to the left of the direction of travel. After the alignment the center of lane 1 lies at about 2 m.
Lane numbers 1 = rightmost main lane of the widest cross-section, increasing to the left. 0 = auxiliary lane (on-ramp, off-ramp, acceleration or deceleration lane), only inside configured auxiliary-lane zones. -1 = unassigned. Where lanes are added or dropped (lane-count zones), numbers stay those of the widest cross-section.
Neighbor sides *_left = lane + 1, *_right = lane − 1. A vehicle in lane 1 sees lane-0 vehicles as right neighbors.
Lane-change direction lc_direction = +1 = left = toward a higher lane number (increasing pos_lat); -1 = right. A merge from lane 0 to lane 1 is a left lane change.
Time grid One common grid t0 + k / rate for all vehicles (default 10 Hz), t0 counted in whole grid steps from the Unix epoch. Each vehicle has rows only within its observed time span.
Units Positions and distances in m, speed in km/h, acceleration in m/s², durations in s.
Missing values Floats: NaN (for example no neighbor); times: NaT; lanes: -1 = unassigned. Neighbor IDs are float columns because they can be NaN.
Rounding All float64 columns are rounded to PipelineConfig.round_decimals decimals at the end (default 2; None keeps full precision). This includes lane_confidence.

Trajectory columns

Which columns appear depends on the configuration. "Step" names the pipeline step that writes the column.

Identification and input columns

Column Unit dtype Definition
id – as input (int64 from the readers) Vehicle ID. After stitching, linked fragments carry one common ID (the smallest by string order).
datum – datetime64[ns] Time stamp of the grid point.
geometry – Point Position. Rebuilt from utm_x/utm_y on the output grid if these columns exist; for road-aligned input, Point(pos_lon, pos_lat) of the input.
utm_x, utm_y m float64 Planar position, if present in the input (interpolated on the output grid).
class – str Vehicle class as given in the input. The readers use Car, Van, Truck, Bus, Motorcycle, Other (see readers.md).
length m float64 Vehicle length, if present in the input. Neighbor clearances use 4.5 m where it is missing.
orientation – float64 Travel direction of the vehicle in the input (+1 / −1), if present.
other input columns – – Passed through. On the output grid, unknown float columns are interpolated linearly, all others take the nearest native sample (override with resampling.interpolate_columns, nearest_columns, drop_columns). Examples from the readers: width, class_provider, lane_gt, lane_provider.

Position (Steps 1–3)

Column Unit dtype Step Definition
pos_lon m float64 projection, kinematics s along the reference line in the direction of travel. With Montanino & Punzo kinematics, the reconstructed position.
pos_lat m float64 projection, perspective, alignment, kinematics d, positive to the left; heavy-vehicle rows shifted by the perspective correction, aligned to the road edge (lane-1 center ≈ 2 m), smoothed with Savitzky-Golay.
pos_lon_ref m float64 projection Stationing along the reference line in its digitizing direction (equals pos_lon unless the line was reversed).
ref_line_reversed – bool projection True if the reference line ran against the traffic and s, d were flipped.
pos_lat_raw m float64 alignment pos_lat before the alignment (after any perspective correction, before smoothing).
y_correction m float64 alignment Smoothed road-edge profile y(s) that was subtracted: aligned d = pos_lat_raw − y_correction + alignment.target_offset_m (2 m) before the Step 3 smoothing.
is_imputed – bool imputation (optional) True for rows filled by the imputation (no original sample within half a frame).

Road-aligned datasets (highD, RWTH A43, NGSIM, UTE) already carry pos_lon and pos_lat; the projection is skipped, so pos_lon_ref and ref_line_reversed are absent.

Kinematics (Step 3)

Column Unit dtype Definition
speed km/h float64 Longitudinal speed along s.
acceleration m/s² float64 Longitudinal acceleration along s.
mp_reconstructed – bool True for samples changed by Step 1 (outlier replacement) or Step 3 (constrained reconstruction) of the Montanino & Punzo method. Only with kinematics.method = "montanino_punzo"; always False for tracks that fell back to Savitzky-Golay.

With kinematics.mp.trim_track_ends_sec set, rows at track ends whose acceleration stayed outside [−8, 5] m/s² are removed (not flagged); counts are in the run metadata.

Lanes (Steps 4–5)

Column Unit dtype Written by Definition
lane – int64 lanes, lane_correction Lane used by Step 6. Step 4 writes the point-wise label (nearest lane center); Step 5 overwrites it with lane_fixed. In the final output lane equals lane_fixed unless Step 5 is disabled.
lane_fixed – int64 lane_correction Consistent lane sequence of the vehicle after Step 5 (heuristic or HMM, including the cross-vehicle conflict resolution).
is_changing_lane – bool lane_correction Sample lies inside a lane change (from the detector interval of a maneuver that ends in another lane).
is_lateral_excursion – bool lane_correction Sample lies inside a lateral excursion: a detected lateral maneuver that does not end in another lane (aborted lane change, large movement within the lane). The lane does not change.
lane_conflict_resolved – bool lane_correction (heuristic only) The lane of this row was changed by the cross-vehicle conflict resolution (two vehicles overlapping in one lane).
lane_fixed_unresolved – int64 lane_correction (with lanes.keep_unresolved_lane = True) lane_fixed before the cross-vehicle conflict resolution (for evaluation).
lane_confidence – (0–1) float64 lane_correction (HMM only) Posterior probability of the decoded lane (forward–backward).
lane_posterior_margin – (0–1) float64 lane_correction (HMM only) Posterior of the decoded lane minus that of the second most probable lane.
suspected_duplicate_track – bool lane_correction (HMM only) Row belongs to a long (> 1 s), confident (posterior > 0.9) overlap with another track less than 0.5 m away laterally: probably two tracks of one vehicle. Not re-assigned.
lane_conflict_unresolved – bool lane_correction (HMM only) A space-time conflict with another vehicle in the same lane remains on this row (not resolved within the iteration limit, or, with damped resolution, shorter than t_min).

Surroundings (Step 6)

For each of the six positions front, rear, front_left, rear_left, front_right, rear_right there are four columns (24 in total), computed at the identical grid time:

Column pattern Unit dtype Definition
id_<position> – float64 ID of the neighbor; NaN if there is none.
headway_<position> m float64 Center-to-center distance along the direction of travel (positive).
clearance_<position> m float64 Bumper-to-bumper distance: headway − (L_subject + L_neighbor) / 2. Can be negative for overlapping vehicles, and for an adjacent-lane vehicle exactly side by side (within 1 mm), which counts as a rear neighbor.
rel_speed_<position> km/h float64 Neighbor speed minus own speed.

front means larger pos_lon. *_left refers to lane + 1, *_right to lane − 1. Rows with lane -1 have no neighbors and are nobody's neighbor.

Flags and columns that do not exist

The pipeline does not produce class probabilities (class_prob), lane probabilities per lane, interpolated, or predicted columns. The equivalents are:

  • rows filled across gaps: is_imputed (only with the imputation step);
  • rows changed by the kinematic reconstruction: mp_reconstructed;
  • confidence of the lane: lane_confidence and lane_posterior_margin (HMM only; posterior of the decoded lane, not a full distribution over lanes);
  • events near the section ends: near_road_end (event table only, not a trajectory column).

Readers that receive class probabilities from a dataset (DLR Highway Traffic) keep only the most probable class.

Lane-change event table

Returned as run_pipeline_detailed(...).events. One row per detected lateral maneuver.

Column Unit dtype Definition
id – int64 Vehicle ID.
class – str Vehicle class.
event_type – str lane_change or lateral_excursion.
lc_direction – int64 +1 = left (toward a higher lane number), −1 = right.
direction – float64 Travel direction of the vehicle from the input column orientation (+1 / −1); NaN if the input has no orientation. Not the side of the maneuver.
time_start, time_end – datetime64[ns] Start and end of the maneuver (detector interval: smoothed lateral speed above 0.1 m/s). For HMM lane changes without a detector interval, where the smoothed lateral speed drops below the threshold.
time_lc – datetime64[ns] Time of the peak smoothed lateral speed.
time_cross – datetime64[ns] Lane changes: time of the boundary crossing (heuristic: midpoint between the two lane centers). NaT for excursions.
duration_sec s float64 time_end − time_start.
frame_lc – float64 Sample index of the peak, counted at the nominal frame rate from the vehicle's first sample.
lane_start, lane_end – int64 (heuristic), float64 (HMM) Lane label at the start and end of the detector interval, as seen by the detector (point-wise labels).
lane_before, lane_after – int64 Assigned lane (lane_fixed) before and after the maneuver. Equal for excursions.
max_lateral_offset_m m float64 Excursions: largest signed lateral offset from the start-lane center. NaN for lane changes.
speed_start, speed_lc, speed_end km/h float64 Speed at start, peak, and end.
pos_lon_lc m float64 pos_lon at the peak.
{id, headway, clearance, rel_speed}_{front, rear}_start as above float64 Leader and follower in the target lane at time_start.
{id, headway, clearance, rel_speed}_{front, rear}_lc as above float64 Leader and follower in the vehicle's own lane at time_lc.
{id, headway, clearance, rel_speed}_{front, rear}_end as above float64 Leader and follower in the vehicle's own lane at time_end.
detected_by – str HMM only: detector+hmm (lane change inside a detector interval) or hmm (decoded without a detector interval, for example a slow drift).
near_road_end – bool Crossing (lane changes) or peak (excursions) within lane_change.edge_buffer_m (30 m) of either end of the section. Exclude these from behavioral statistics.

The neighbor attributes are taken from the output grid at the nearest grid time within half a grid step; they are NaN where there is no neighbor or no matching grid row.

Run metadata (out.attrs["trajlab"])

A JSON-compatible dict; with metadata_path=... it is also written as a JSON file. Read it with trajlab.run_metadata(out) (module trajlab.metadata), which returns out.attrs["trajlab"].

Key Content
timestamp_utc Time of the run (ISO 8601, UTC).
library name, version, git_commit (None outside a git checkout).
python Python version.
dependencies Versions of numpy, pandas, scipy, scikit-learn, shapely, geopandas, networkx.
config The full configuration (PipelineConfig.to_dict()); PipelineConfig.from_dict rebuilds it.
input, output rows and vehicles of the input and the output.
steps One record per step: step, status (ran, skipped because its outputs existed, or disabled), rows_in, rows_out, vehicles_in, vehicles_out, seconds.
perspective The applied perspective correction, or None without one (see below).
lane_geometry Step 4 diagnostics: gmm_model, windows, windows_lane_lost and windows_lane_lost_share (windows in which a tracked lane got no center from the window fit), centre_sd_m (per lane, standard deviation of its center along s; ideally close to 0 after the alignment).
mp_counters Montanino & Punzo counters: vehicles, vehicles_too_short (fell back to Savitzky-Golay), outlier_positions, windows, windows_enlarged, windows_failed, output_rows_from_grid, and with track-end trimming trim_track_ends (rows_removed, ends_cut, tracks_removed).

Keys of perspective by correction:

Correction Keys
class_offset_empirical_view applied, source (estimated or config), view_source (hgv_band, seams or config), view_boundaries_m, seam_boundaries_m, offset_view_m (one offset per view, m), offset_m (direction-wide fallback estimate), residuals_m and view_residuals_m (iteration history), views (per view: view, start_m, end_m, n_hgv, candidates with delta, within_0_5m, lane1_share; chosen_delta, ambiguous, changed_reading, fallback, robust_skip), limited (per view: offset beyond view_max_offset_m, replaced by the fallback), band_profile.
class_offset_empirical applied, offset_m (for example {"hgv": δ}), source, residuals_m.
constant_class_offset applied, offset_m, source.
lateral_class_offset applied, kappa, d_c_m, source (or fit when the fit failed).
joint_gmm delta_global, delta_lane or delta_section, modes, mode_by_posterior, profile, profile_diagnosis, hgv_lane_share, runtime_s.

To check a per-view correction, look at views[*].ambiguous, robust_skip, fallback, and the candidates: a chosen offset that differs by about one lane width from a candidate near 0 with a similar within_0_5m share is a sign of a reading one lane off (3.3–3.7 m in the documented cases) (see limitations.md).

Context artifacts

With run_pipeline_detailed(..., keep_intermediates=True) the result also holds a dict step name → DataFrame after that step (intermediates). Results that are not columns are passed from step to step in PipelineContext.artifacts. run_pipeline_detailed does not return the context; the artifacts a user needs are copied into the result:

Artifact Returned as
lane_change_events run_pipeline_detailed(...).events
perspective perspective in the run metadata
lane_geometry_diagnostics lane_geometry in the run metadata
mp_counters mp_counters in the run metadata

The other artifacts (lane_centers, the HMM geometry lane_geometry, hmm_em_history, hmm_conflict_history, stitch_links, mp_grid, mp_platoon) are available only to code that runs the steps of trajlab.PIPELINE_STEPS itself with a PipelineContext.