TrajectoryCollection#
- class movingpandas.TrajectoryCollection(data, traj_id_col=None, obj_id_col=None, t=None, x=None, y=None, crs='epsg:4326', min_length=0, min_duration=None)#
- __init__(data, traj_id_col=None, obj_id_col=None, t=None, x=None, y=None, crs='epsg:4326', min_length=0, min_duration=None)#
Create TrajectoryCollection from list of trajectories or GeoDataFrame
- Parameters:
data (list[Trajectory] or GeoDataFrame or DataFrame) – List of Trajectory objects or a GeoDataFrame with trajectory IDs, point geometry column and timestamp index
traj_id_col (string) – Name of the GeoDataFrame column containing trajectory IDs
obj_id_col (string) – Name of the GeoDataFrame column containing moving object IDs
t (string) – Name of the DataFrame column containing the timestamp
x (string) – Name of the DataFrame column containing the x coordinate
y (string) – Name of the DataFrame column containing the y coordinate
crs (string) – CRS of the x/y coordinates
min_length (numeric) – Desired minimum length of trajectories. Length is calculated using CRS units, except if the CRS is geographic (e.g. EPSG:4326 WGS84) then length is calculated in meters. (Shorter trajectories are discarded.)
min_duration (timedelta) – Desired minimum duration of trajectories. (Shorter trajectories are discarded.)
Examples
>>> import geopandas as read_file >>> import movingpandas as mpd >>> >>> gdf = read_file('data.gpkg') >>> collection = mpd.TrajectoryCollection(gdf, 'trajectory_id', t='t')
Conversion#
|
Return the trajectories' line segments as GeoDataFrame. |
Converts a TrajectoryCollection to a dictionary compatible with the Moving Features JSON (MF-JSON) specification. |
|
Return the trajectories' points as GeoDataFrame. |
|
|
Return a GeoDataFrame with one row per Trajectory within the TrajectoryCollection |
Enrichment#
Add acceleration column and values to the trajectories. |
|
Add angular difference to the trajectory's DataFrame. |
|
Add direction column and values to the trajectories. |
|
Add distance column and values to the trajectories. |
|
|
Add speed column and values to the trajectories. |
Add timedelta column and values to the trajectories. |
|
|
Add trajectory id column and values to the trajectories. |
General methods and attributes#
Return a copy of the trajectory collection. |
|
|
Drop columns or rows from the trajectories' DataFrames |
|
Filter trajectories by property |
|
Return maximum value in the provided DataFrame column over all trajectories |
|
Return minimum value in the provided DataFrame column over all trajectories |
Return the trajectories of the requested moving object |
|
|
Return the Trajectory with the requested ID |
Plotting#
|
Generate a plot using GeoPandas explore (folium/leaflet.js) https://geopandas.org/en/stable/docs/reference/api/geopandas.GeoDataFrame.explore.html |
|
Generate an interactive trajectory plot. |
|
Generate an interactive plot of trajectory points. |
|
Generate a plot. |
Spatiotemporal analysis#
|
Clip trajectories by the given polygon. |
Return the CRS of the trajectories |
|
Returns GeoDataFrame with trajectory end locations |
|
Return trajectories that intersect the given polygon. |
|
|
Returns GeoDataFrame with trajectory locations at the specified timestamp |
Return Trajectory segments between times t1 and t2. |
|
Returns GeoDataFrame with trajectory start locations |
|
|
Intersect trajectories with the given polygon feature. |
Return True if the trajectory CRS is geographic (e.g. EPSG:4326 WGS84). |
Spatiotemporal columns#
Return the list of column names |
|
Return name of the direction column |
|
Return name of the geometry column |
|
Return name of the speed column |
|
Return name of the trajectory ID column |