Triplegs
Triplegs summarizes one movement segment between consecutive staypoints. Each
row describes a door-to-door segment rather than its raw point geometry, making
it suitable for mode classification and trip aggregation.
Required data
Validated triplegs contain tripleg_id, started_at, finished_at,
length_km, and duration_s, plus a user ID when the data represents multiple
people. Generated triplegs also include mean speed information.
generate_trips() requires staypoints with an activity flag. Create that flag
first with Staypoints.create_activity_flag().
API
fastmob.core.triplegs_dataframe.Triplegs
Bases: BaseDataFrame
One row per tripleg (a movement segment between two staypoints).
.df is the per-tripleg summary table: tripleg_id, started_at,
finished_at, length_km, duration_s, mean_speed_kmh, plus
uid_col when present. Reconstructing each tripleg's point-by-point
geometry (e.g. for a LineString) is not built in this pass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame - like
|
Source data; any Narwhals-compatible eager backend. |
required |
uid_col
|
str
|
User-ID column name. |
None
|
validate
|
bool
|
When True (default), check that required columns are present. |
True
|
calculate_modal_split(freq=None, metric='count', per_user=False, normalize=False)
from_positionfixes(positionfixes, staypoints, gap_threshold_min=15.0, **stop_kwargs)
staticmethod
Derive triplegs from positionfixes + already-generated staypoints.
See :meth:fastmob.core.positionfixes_dataframe.Positionfixes.generate_triplegs.
Returns:
| Type | Description |
|---|---|
Triplegs
|
Movement segments derived from the raw fixes and stops. |
Examples:
generate_trips(staypoints, gap_threshold_min=15.0)
predict_transport_mode(method='simple-coarse', categories=None)
Classify each tripleg's transport mode from its average speed.
See :func:fastmob.preprocessing.predict_transport_mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
str
|
Classification method. Default is |
'simple-coarse'
|
categories
|
dict or None
|
Custom speed-to-mode categories. |
None
|
Returns:
| Type | Description |
|---|---|
Triplegs
|
Copy with a |
Examples: