movingpandas.Trajectory.add_speed#
- Trajectory.add_speed(overwrite=False, name='speed', units=(None, None, None, None))#
Add speed column and values to the trajectory’s DataFrame.
Speed values are computed between the current point and the previous:
If no units have been declared:
For geographic projections, in meters per second
For other projections, in CRS units per second
If units have been declared:
For geographic projections, in declared units
For known CRS units, in declared units
For unknown CRS units, in declared units as if CRS distance units are meters
- Parameters:
overwrite (bool) – Whether to overwrite existing speed values (default: False)
name (str) – Name of the speed column (default: “speed”)
units (tuple(str)) –
Units in which to calculate speed
- distancestr
Abbreviation for the distance unit (default: CRS units, or metres if geographic)
- timestr
Abbreviation for the time unit (default: seconds)
For more info, check the list of supported units at https://movingpandas.org/units
Examples
If no units are declared, the speed will be calculated in meters per second for geographic projections (e.g. EPSG:4326 WGS84) and in CRS distance units per second for all other projections
>>>traj.add_speed()
The default column name is “speed”. If a column of this name already exists, a new column name can be specified
>>>traj.add_speed(name=”speed (CRS units)”)
If units are declared, the speed will be calculated in those units except if the CRS distance units are unknown, in which case the CRS distance units are assumed to be meters
>>>traj.add_speed(units=(“km”, “h”))
It is suggested to declare a name for the new column specifying units
>>>traj.add_speed(name=”speed (mph)”, units=(“mi”, “h”)) >>>traj.add_speed(name=”US Survey Feet/s”, units=(“survey_ft”, “s”))