mobilipy.plot

Functions

get_leg_points(legs_from_waypoints, ...[, info])

Returns a DataFrame with all the points belonging to the given leg.

get_map_bounds(df)

Finds the map bounding box for the given WaypointsDataFrame

plot_all(legs_from_waypoints, waypoints)

Plots dirty waypoints, clean waypoints and resulting legs.

plot_daily_legs(legs_from_waypoints, ...[, ...])

Plots all the legs for a given day

plot_gps(df[, loc_map, type_, line])

Plots supplied GPS points on a folium Map.

plot_leg(legs_from_waypoints, ...[, map_, info])

Plots a selected leg on a folium Map.

plot_legs(legs_from_waypoints, clean_waypoints)

Plots all the legs on a folium Map

plot_solos(solos[, map_])

Plots DataFrame points on a folium Map without connecting them with a line.

plot_waypoints(waypoints[, clean_df, map_])

Plots waypoints on a folium Map.

mobilipy.plot.get_leg_points(legs_from_waypoints, clean_waypoints, index, info=False)

Returns a DataFrame with all the points belonging to the given leg.

Parameters
  • legs_from_waypoints (pd.DataFrame) – DataFrame with legs, coming from legs.get_user_legs.

  • clean_waypoints (pd.DataFrame) – DataFrame with latitude, longitude and tracked_at columns.

  • index (int) – Index of the leg.

  • info (bool, optional) – Defines whether additional info about the leg should be returned. Defaults to False.

Returns

pd.DataFrame – DataFrame with all the points belonging to the given leg

mobilipy.plot.get_map_bounds(df)

Finds the map bounding box for the given WaypointsDataFrame

Parameters

df (pd.DataFrame) – DataFrame with latitude and longitude columns

Returns

((float, float), (float, float)) – Bounds as a 2x2 array, in the form of ((latitude_min, longitude_min), (latitude_max, longitude_max))

mobilipy.plot.plot_all(legs_from_waypoints, waypoints)

Plots dirty waypoints, clean waypoints and resulting legs.

Parameters
  • legs_from_waypoints (pd.DataFrame) – DataFrame with legs, coming from legs.get_user_legs.

  • waypoints (pd.DataFrame) – DataFrame with latitude, longitude and tracked_at columns.

Returns

folium.Map – Map with points from the DataFrames

mobilipy.plot.plot_daily_legs(legs_from_waypoints, waypoints, day_num, first_=0, last_=- 1, map_=None, dirty_waypoints=False, plot_waypoints=False, solos=False)

Plots all the legs for a given day

Parameters
  • legs_from_waypoints (pd.DataFrame) – DataFrame with legs, coming from legs.get_user_legs.

  • waypoints (pd.DataFrame) – DataFrame with latitude, longitude and tracked_at columns.

  • day_num (int) – Index of the day

  • first (int, optional) – Index of the first leg to be plotted. Defaults to 0.

  • last (int, optional) – Index of the last leg to be plotted. Defaults to -1.

  • map ([type], optional) – Existing Map object to plot the points on. Defaults to None.

  • dirty_waypoints (bool, optional) – Specifies whether the supplied waypoints need cleaning. Defaults to False.

  • plot_waypoints (bool, optional) – Specifies whether waypoints should be plotted one by one. Defaults to False.

  • solos (bool, optional) – Specifies whether solo legs should be plotted. Defaults to False.

Returns

folium.Map – Map with points from the DataFrames

mobilipy.plot.plot_gps(df, loc_map=None, type_='transport', line=True)

Plots supplied GPS points on a folium Map.

Parameters
  • df (pd.DataFrame) – DataFrame with latitude, longitude and tracked_at columns.

  • loc_map (folium.Map, optional) – Existing Map object to plot the points on. Defaults to None.

  • type (str, optional) – Type of data, can TRANSPORT, ACTIVITY. Defaults to TRANSPORT.

  • line (bool, optional) – Specifies whether consecutive points should be connected by a line. Defaults to True.

Returns

folium.Map – Map with points from the DataFrame

mobilipy.plot.plot_leg(legs_from_waypoints, clean_waypoints, index, map_=None, info=False)

Plots a selected leg on a folium Map.

Parameters
  • legs_from_waypoints (pd.DataFrame) – DataFrame with legs, coming from legs.get_user_legs.

  • clean_waypoints (pd.DataFrame) – DataFrame with latitude, longitude and tracked_at columns.

  • index (int) – Index of the leg.

  • map ([type], optional) – Existing Map object to plot the points on. Defaults to None.

  • info (bool, optional) – Defines whether additional info about the leg should be returned. Defaults to False.

Returns

folium.Map – Map with points from the leg

mobilipy.plot.plot_legs(legs_from_waypoints, clean_waypoints, map_=None)

Plots all the legs on a folium Map

Parameters
  • legs_from_waypoints (pd.DataFrame) – DataFrame with legs, coming from legs.get_user_legs.

  • clean_waypoints (pd.DataFrame) – DataFrame with latitude, longitude and tracked_at columns.

  • map ([type], optional) – Existing Map object to plot the points on. Defaults to None.

Returns

folium.Map – Map with points from the legs DataFrame

mobilipy.plot.plot_solos(solos, map_=None)

Plots DataFrame points on a folium Map without connecting them with a line.

Parameters
  • solos (pd.DataFrame) – DataFrame with latitude, longitude and tracked_at columns.

  • map (folium.Map, optional) – Existing Map object to plot the points on. Defaults to None.

Returns

folium.Map – Map with points from the DataFrame

mobilipy.plot.plot_waypoints(waypoints, clean_df=True, map_=None)

Plots waypoints on a folium Map.

Parameters
  • waypoints (pd.DataFrame) – DataFrame with latitude, longitude and tracked_at columns.

  • clean_df (bool, optional) – Prepares waypoints before plotting if True. Defaults to True.

  • map (folium.Map, optional) – Existing Map object to plot the points on. Defaults to None.

Returns

folium.Map – Map with points from the DataFrame