pymove.visualization package¶
Submodules¶
pymove.visualization.folium module¶
Folium operations.
save_map, create_base_map, heatmap, heatmap_with_time, cluster, faster_cluster, plot_markers, plot_trajectories, plot_trajectory_by_id, plot_trajectory_by_period, plot_trajectory_by_day_week, plot_trajectory_by_date, plot_trajectory_by_hour, plot_stops, plot_bbox, plot_points, plot_poi, plot_event, plot_traj_timestamp_geo_json
-
pymove.visualization.folium.
cluster
(move_data: DataFrame, n_rows: int | None = None, lat_origin: float | None = None, lon_origin: float | None = None, zoom_start: float = 12, base_map: Map | None = None, tile: str = 'CartoDB positron', save_as_html: bool = False, filename: str = 'cluster.html') → Map[source]¶ Generate visualization of Heat Map using folium plugin.
Parameters: - move_data (DataFrame) – Input trajectory data
- n_rows (int, optional) – Represents number of data rows that are will plot, by default None
- lat_origin (float, optional) – Represents the latitude which will be the center of the map, by default None
- lon_origin (float, optional) – Represents the longitude which will be the center of the map, by default None
- zoom_start (float, optional) – Initial zoom level for the map, by default 12
- radius (float, optional) – Radius of each “point” of the heatmap, by default 8
- base_map (Map, optional) – Represents the folium map. If not informed, a new map is generated using the function create_base_map(), with the lat_origin, lon_origin and zoom_start, by default None
- tile (str, optional) – Represents the map tiles, by default TILES[0]
- save_as_html (bool, optional) – Represents if want save this visualization in a new file .html, by default False
- filename (str, optional) – Represents the file name of new file .html, by default ‘cluster.html’
Returns: folium Map
Return type: Map
Examples
>>> from pymove.visualization.folium import cluster >>> move_df.head() lat lon datetime id 0 39.984094 116.319236 2008-10-23 05:53:05 1 1 39.984198 116.319322 2008-10-23 05:53:06 1 2 39.984224 116.319402 2008-10-23 05:53:11 1 3 39.984211 116.319389 2008-10-23 05:53:16 1 4 39.984217 116.319422 2008-10-23 05:53:21 1 >>> cluster(move_df)
-
pymove.visualization.folium.
create_base_map
(move_data: DataFrame, lat_origin: float | None = None, lon_origin: float | None = None, tile: str = 'CartoDB positron', default_zoom_start: float = 12) → Map[source]¶ Generates a folium map.
Parameters: - move_data (DataFrame) – Input trajectory data
- lat_origin (float, optional) – Represents the latitude which will be the center of the map, by default None
- lon_origin (float, optional) – Represents the longitude which will be the center of the map, by default None
- tile (str, optional) – Represents the map tiles, by default TILES[0]
- default_zoom_start (float, optional) – Represents the zoom which will be the center of the map, by default 12
Returns: a folium map
Return type: Map
Examples
>>> from pymove.visualization.folium import create_base_map >>> move_df.head() lat lon datetime id 0 39.984094 116.319236 2008-10-23 05:53:05 1 1 39.984198 116.319322 2008-10-23 05:53:06 1 2 39.984224 116.319402 2008-10-23 05:53:11 1 3 39.984211 116.319389 2008-10-23 05:53:16 1 4 39.984217 116.319422 2008-10-23 05:53:21 1 >>> create_base_map(move_df)
-
pymove.visualization.folium.
faster_cluster
(move_data: DataFrame, n_rows: int | None = None, lat_origin: float | None = None, lon_origin: float | None = None, zoom_start: float = 12, base_map: Map | None = None, tile: str = 'CartoDB positron', save_as_html: bool = False, filename: str = 'faster_cluster.html') → Map[source]¶ Generate visualization of Heat Map using folium plugin.
Parameters: - move_data (DataFrame) – Input trajectory data
- n_rows (int, optional) – Represents number of data rows that are will plot, by default None
- lat_origin (float, optional) – Represents the latitude which will be the center of the map, by default None
- lon_origin (float, optional) – Represents the longitude which will be the center of the map, by default None
- zoom_start (float, optional) – Initial zoom level for the map, by default 12
- radius (float, optional) – Radius of each “point” of the heatmap, by default 8
- base_map (Map, optional) – Represents the folium map. If not informed, a new map is generated using the function create_base_map(), with the lat_origin, lon_origin and zoom_start, by default None
- tile (str, optional) – Represents the map tiles, by default TILES[0]
- save_as_html (bool, optional) – Represents if want save this visualization in a new file .html, by default False
- filename (str, optional) – Represents the file name of new file .html, by default ‘faster_cluster.html’
Returns: folium Map
Return type: Map
Examples
>>> from pymove.visualization.folium import faster_cluster >>> move_df.head() lat lon datetime id 0 39.984094 116.319236 2008-10-23 05:53:05 1 1 39.984198 116.319322 2008-10-23 05:53:06 1 2 39.984224 116.319402 2008-10-23 05:53:11 1 3 39.984211 116.319389 2008-10-23 05:53:16 1 4 39.984217 116.319422 2008-10-23 05:53:21 1 >>> faster_cluster(move_df)
-
pymove.visualization.folium.
heatmap
(move_data: DataFrame, n_rows: int | None = None, lat_origin: float | None = None, lon_origin: float | None = None, zoom_start: float = 12, radius: float = 8, base_map: Map | None = None, tile: str = 'CartoDB positron', save_as_html: bool = False, filename: str = 'heatmap.html') → Map[source]¶ Generate visualization of Heat Map using folium plugin.
Parameters: - move_data (DataFrame) – Input trajectory data
- n_rows (int, optional) – Represents number of data rows that are will plot, by default None
- lat_origin (float, optional) – Represents the latitude which will be the center of the map, by default None
- lon_origin (float, optional) – Represents the longitude which will be the center of the map, by default None
- zoom_start (float, optional) – Initial zoom level for the map, by default 12
- radius (float, optional) – Radius of each “point” of the heatmap, by default 8
- base_map (Map, optional) – Represents the folium map. If not informed, a new map is generated using the function create_base_map(), with the lat_origin, lon_origin and zoom_start, by default None
- tile (str, optional) – Represents the map tiles, by default TILES[0]
- save_as_html (bool, optional) – Represents if want save this visualization in a new file .html, by default False
- filename (str, optional) – Represents the file name of new file .html, by default ‘heatmap.html’
Returns: folium Map
Return type: Map
Examples
>>> from pymove.visualization.folium import heatmap >>> move_df.head() lat lon datetime id 0 39.984094 116.319236 2008-10-23 05:53:05 1 1 39.984198 116.319322 2008-10-23 05:53:06 1 2 39.984224 116.319402 2008-10-23 05:53:11 1 3 39.984211 116.319389 2008-10-23 05:53:16 1 4 39.984217 116.319422 2008-10-23 05:53:21 1 >>> heatmap(move_df)
-
pymove.visualization.folium.
heatmap_with_time
(move_data: DataFrame, n_rows: int | None = None, lat_origin: float | None = None, lon_origin: float | None = None, zoom_start: float = 12, radius: float = 8, min_opacity: float = 0.5, max_opacity: float = 0.8, base_map: Map | None = None, tile: str = 'CartoDB positron', save_as_html: bool = False, filename: str = 'heatmap_time.html') → Map[source]¶ Generate visualization of Heat Map using folium plugin.
Parameters: - move_data (DataFrame) – Input trajectory data
- n_rows (int, optional) – Represents number of data rows that are will plot, by default None
- lat_origin (float, optional) – Represents the latitude which will be the center of the map, by default None
- lon_origin (float, optional) – Represents the longitude which will be the center of the map, by default None
- zoom_start (float, optional) – Initial zoom level for the map, by default 12
- radius (float, optional) – Radius of each “point” of the heatmap, by default 8
- min_opacity (float, optional) – Minimum heat opacity, by default 0.5.
- max_opacity (float, optional) – Maximum heat opacity, by default 0.8.
- base_map (Map, optional) – Represents the folium map. If not informed, a new map is generated using the function create_base_map(), with the lat_origin, lon_origin and zoom_start, by default None
- tile (str, optional) – Represents the map tiles, by default TILES[0]
- save_as_html (bool, optional) – Represents if want save this visualization in a new file .html, by default False
- filename (str, optional) – Represents the file name of new file .html, by default ‘heatmap_time.html’
Returns: folium Map
Return type: Map
Examples
>>> from pymove.visualization.folium import heatmap_with_time >>> move_df.head() lat lon datetime id 0 39.984094 116.319236 2008-10-23 05:53:05 1 1 39.984198 116.319322 2008-10-23 05:53:06 1 2 39.984224 116.319402 2008-10-23 05:53:11 1 3 39.984211 116.319389 2008-10-23 05:53:16 1 4 39.984217 116.319422 2008-10-23 05:53:21 1 >>> heatmap_with_time(move_df)
-
pymove.visualization.folium.
plot_bbox
(bbox_tuple: tuple[float, float, float, float], base_map: Map | None = None, tiles: str = 'CartoDB positron', color: str = 'red', save_as_html: bool = False, filename: str = 'bbox.html') → Map[source]¶ Plots a bbox using Folium.
Parameters: - bbox_tuple (tuple.) – Represents a bound box, that is a tuple of 4 values with the min and max limits of latitude e longitude.
- base_map (Folium map, optional) – A folium map to plot the trajectories. If None a map will be created, by default None.
- tiles (str, optional) – by default TILES[0]
- color (str, optional) – Represents color of lines on map, by default ‘red’.
- file (str, optional) – Represents filename, by default ‘bbox.html’.
- save_map (Boolean, optional) – Wether to save the bbox folium map, by default False.
Returns: folium map with bounding box
Return type: Map
Examples
>>> from pymove.visualization.folium import plot_bbox >>> plot_bbox((39.984094,116.319236,39.997535,116.196345))
-
pymove.visualization.folium.
plot_event
(move_data: DataFrame, event_lat: str = 'lat', event_lon: str = 'lon', event_point: str = 'purple', radius: float = 2, base_map: Map | None = None, slice_tags: list | None = None, tiles: str = 'CartoDB positron', save_as_html: bool = False, filename: str = 'events.html') → Map[source]¶ Receives a MoveDataFrame and returns a folium map with events.
Parameters: - move_data (DataFrame) – Trajectory input data
- event_lat (str, optional) – Latitude column name, by default LATITUDE.
- event_lon (str, optional) – Longitude column name, by default LONGITUDE.
- event_point (str, optional) – Event color, by default EVENT_POI
- radius (float, optional) – radius size, by default 2.
- base_map (Folium map, optional) – A folium map to plot. If None a map. If None a map will be created, by default None.
- tiles (str, optional, by default TILES[0]) –
- save_as_html (bool, optional) – Represents if want save this visualization in a new file .html, by default False.
- filename (str, optional) – Represents the file name of new file .html, by default ‘events.html’.
Returns: Return type: A folium map.
Examples
>>> from pymove.visualization.folium import plot_event >>> move_df.head() lat lon datetime id 0 39.984094 116.319236 2008-10-23 05:53:05 1 1 39.984198 116.319322 2008-10-23 05:53:06 1 2 39.984224 116.319402 2008-10-23 05:53:11 1 3 39.984211 116.319389 2008-10-23 05:53:16 1 4 39.984217 116.319422 2008-10-23 05:53:21 1 >>> plot_event(move_df)
-
pymove.visualization.folium.
plot_markers
(move_data: DataFrame, n_rows: int | None = None, lat_origin: float | None = None, lon_origin: float | None = None, zoom_start: float = 12, base_map: Map | None = None, tile: str = 'CartoDB positron', save_as_html: bool = False, filename: str = 'markers.html') → Map[source]¶ Generate visualization of Heat Map using folium plugin.
Parameters: - move_data (DataFrame) – Input trajectory data
- n_rows (int, optional) – Represents number of data rows that are will plot, by default None
- lat_origin (float, optional) – Represents the latitude which will be the center of the map, by default None
- lon_origin (float, optional) – Represents the longitude which will be the center of the map, by default None
- zoom_start (float, optional) – Initial zoom level for the map, by default 12
- radius (float, optional) – Radius of each “point” of the heatmap, by default 8
- base_map (Map, optional) – Represents the folium map. If not informed, a new map is generated using the function create_base_map(), with the lat_origin, lon_origin and zoom_start, by default None
- tile (str, optional) – Represents the map tiles, by default TILES[0]
- save_as_html (bool, optional) – Represents if want save this visualization in a new file .html, by default False
- filename (str, optional) – Represents the file name of new file .html, by default ‘markers.html’
Returns: folium Map
Return type: Map
Examples
>>> from pymove.visualization.folium import plot_markers >>> move_df.head() lat lon datetime id 0 39.984094 116.319236 2008-10-23 05:53:05 1 1 39.984198 116.319322 2008-10-23 05:53:06 1 2 39.984224 116.319402 2008-10-23 05:53:11 1 3 39.984211 116.319389 2008-10-23 05:53:16 1 4 39.984217 116.319422 2008-10-23 05:53:21 1 >>> plot_markers(move_df)
-
pymove.visualization.folium.
plot_poi
(move_data: DataFrame, poi_lat: str = 'lat', poi_lon: str = 'lon', poi_point: str = 'red', radius: float = 2, base_map: Map | None = None, slice_tags: list | None = None, tiles: str = 'CartoDB positron', save_as_html: bool = False, filename: str = 'pois.html') → Map[source]¶ Receives a MoveDataFrame and returns a folium map with poi points.
Parameters: - move_data (DataFrame) – Trajectory input data
- poi_lat (str, optional) – Latitude column name, by default LATITUDE.
- poi_lon (str, optional) – Longitude column name, by default LONGITUDE.
- poi_point (str, optional) – Poi point color, by default POI_POINT.
- radius (float, optional) – radius size, by default 2.
- base_map (Folium map, optional) – A folium map to plot. If None a map. If None a map will be created, by default None.
- slice_tags (optional, by default None.) –
- tiles (str, optional, by default TILES[0]) – The map type.
- save_as_html (bool, optional) – Represents if want save this visualization in a new file .html, by default False.
- filename (str, optional) – Represents the file name of new file .html, by default ‘pois.html’.
Returns: Represents a folium map with visualization.
Return type: folium.folium.Map.
Examples
>>> from pymove.visualization.folium import plot_poi >>> move_df.head() lat lon datetime id 0 39.984094 116.319236 2008-10-23 05:53:05 1 1 39.984198 116.319322 2008-10-23 05:53:06 1 2 39.984224 116.319402 2008-10-23 05:53:11 1 3 39.984211 116.319389 2008-10-23 05:53:16 1 4 39.984217 116.319422 2008-10-23 05:53:21 1 >>> plot_poi(move_df)
-
pymove.visualization.folium.
plot_points
(move_data: DataFrame, user_lat: str = 'lat', user_lon: str = 'lon', user_point: str = 'orange', radius: float = 2, base_map: Map | None = None, slice_tags: list | None = None, tiles: str = 'CartoDB positron', save_as_html: bool = False, filename: str = 'points.html') → Map[source]¶ Generates a folium map with the trajectories plots and a point.
Parameters: - move_data (Dataframe) – Trajectory data.
- user_lat (str, optional) – Latitude column name, by default LATITUDE.
- user_lon (str, optional) – Longitude column name, by default LONGITUDE.
- user_point (str, optional) – The point color, by default USER_POINT.
- radius (float, optional) – radius size, by default 2.
- sort (Boolean, optional) – If True the data will be sorted, by default False.
- base_map (Folium map, optional) – A folium map to plot the trajectories. If None a map will be created, by default None.
- slice_tags (optional, by default None.) –
- tiles (str, optional, by default TILES[0]) – The map type.
- save_as_html (bool, optional) – Represents if want save this visualization in a new file .html, by default False.
- filename (str, optional) – Represents the file name of new file .html, by default ‘points.html’.
Returns: A folium map
Return type: Map
Examples
>>> from pymove.visualization.folium import plot_points >>> move_df.head() lat lon datetime id 0 39.984094 116.319236 2008-10-23 05:53:05 1 1 39.984198 116.319322 2008-10-23 05:53:06 1 2 39.984224 116.319402 2008-10-23 05:53:11 1 3 39.984211 116.319389 2008-10-23 05:53:16 1 4 39.984217 116.319422 2008-10-23 05:53:21 1 >>> plot_points(move_df)
-
pymove.visualization.folium.
plot_stops
(move_data: PandasMoveDataFrame, radius: float = 0, weight: float = 3, id_: int | None = None, n_rows: int | None = None, lat_origin: float | None = None, lon_origin: float | None = None, zoom_start: float = 12, legend: bool = True, base_map: Map | None = None, tile: str = 'CartoDB positron', save_as_html: bool = False, color: str | list[str] | None = None, filename: str = 'plot_stops.html') → Map[source]¶ Generate visualization of all trajectories with folium.
Parameters: - move_data (DataFrame) – Input trajectory data
- radius (float, optional) – The radius value is used to determine if a segment is a stop. If the value of the point in target_label is greater than radius, the segment is a stop, by default 0
- weight (float, optional) – Stroke width in pixels, by default 3
- id (int, optional) – Trajectory id to plot, by default None
- n_rows (int, optional) – Represents number of data rows that are will plot, by default None.
- lat_origin (float, optional) – Represents the latitude which will be the center of the map. If not entered, the first data from the dataset is used, by default None.
- lon_origin (float, optional) – Represents the longitude which will be the center of the map. If not entered, the first data from the dataset is used, by default None.
- zoom_start (int, optional) – Initial zoom level for the map, by default 12.
- legend (boolean) – Whether to add a legend to the map, by default True
- base_map (folium.folium.Map, optional) –
Represents the folium map. If not informed, a new map is generated using the function create_base_map(), with the lat_origin, lon_origin
and zoom_start, by default None. - tile (str, optional) – Represents the map tiles, by default TILES[0]
- save_as_html (bool, optional) – Represents if want save this visualization in a new file .html, by default False.
- color (str, list, optional) – Represents line colors of visualization. Can be a single color name, a list of colors or a colormap name, by default None.
- filename (str, optional) – Represents the file name of new file .html, by default ‘plot_stops.html’.
Returns: a folium map with visualization
Return type: Map
Raises: KeyError
– If period value is not found in dataframeIndexError
– If there is no user with the id passed
Examples
>>> from pymove.visualization.folium import plot_stops >>> move_df.head() lat lon datetime id 0 39.984094 116.319236 2008-10-23 05:53:05 1 1 39.984198 116.319322 2008-10-23 05:53:06 1 2 39.984224 116.319402 2008-10-23 05:53:11 1 3 39.984211 116.319389 2008-10-23 05:53:16 1 4 39.984217 116.319422 2008-10-23 05:53:21 1 >>> plot_stops(move_df)
-
pymove.visualization.folium.
plot_traj_timestamp_geo_json
(move_data: pandas.core.frame.DataFrame, label_lat: str = 'lat', label_lon: str = 'lon', label_datetime: str = 'datetime', tiles: str = 'CartoDB positron', save_as_html: bool = False, filename: str = 'events.html') → folium.folium.Map[source]¶ Plot trajectories wit geo_json.
Parameters: - move_data (DataFrame.) – Input trajectory data.
- label_datetime (str, optional, by default DATETIME.) – date_time column label.
- label_lat (str, optional, by default LATITUDE.) – latitude column label.
- label_lon (str, optional, by default LONGITUDE.) – longitude column label.
- tiles (str, optional) – map tiles, by default TILES[0]
- save_as_html (bool, optional) – Represents if want save this visualization in a new file .html, by default False.
- filename (str, optional) – Represents the file name of new file .html, by default ‘events.html’.
Returns: A folium map.
Return type: Map
Examples
>>> from pymove.visualization.folium import plot_traj_timestamp_geo_json >>> move_df.head() lat lon datetime id 0 39.984094 116.319236 2008-10-23 05:53:05 1 1 39.984198 116.319322 2008-10-23 05:53:06 1 2 39.984224 116.319402 2008-10-23 05:53:11 1 3 39.984211 116.319389 2008-10-23 05:53:16 1 4 39.984217 116.319422 2008-10-23 05:53:21 1 >>> plot_traj_timestamp_geo_json(move_df)
-
pymove.visualization.folium.
plot_trajectories
(move_data: DataFrame, n_rows: int | None = None, lat_origin: float | None = None, lon_origin: float | None = None, zoom_start: float = 12, legend: bool = True, base_map: Map | None = None, tile: str = 'CartoDB positron', save_as_html: bool = False, color: str | list[str] | None = None, color_by_id: dict | None = None, filename: str = 'plot_trajectories.html') → Map[source]¶ Generate visualization of all trajectories with folium.
Parameters: - move_data (DataFrame) – Input trajectory data.
- n_rows (int, optional) – Represents number of data rows that are will plot, by default None.
- lat_origin (float, optional) – Represents the latitude which will be the center of the map. If not entered, the first data from the dataset is used, by default None.
- lon_origin (float, optional) – Represents the longitude which will be the center of the map. If not entered, the first data from the dataset is used, by default None.
- zoom_start (int, optional) – Initial zoom level for the map, by default 12.
- legend (boolean) – Whether to add a legend to the map, by default True
- base_map (folium.folium.Map, optional) –
Represents the folium map. If not informed, a new map is generated using the function create_base_map(), with the lat_origin, lon_origin
and zoom_start, by default None. - tile (str, optional) – Represents the map tiles, by default TILES[0]
- save_as_html (bool, optional) – Represents if want save this visualization in a new file .html, by default False.
- color (str, list, optional) – Represents line colors of visualization. Can be a single color name, a list of colors or a colormap name, by default None.
- color_by_id (dict, optional) – A dictionary where the key is the trajectory id and value is a color(str), by default None.
- filename (str, optional) – Represents the file name of new file .html, by default ‘plot_trajectory.html’.
Returns: a folium map with visualization.
Return type: Map
Examples
>>> from pymove.visualization.folium import plot_trajectories >>> move_df.head() lat lon datetime id 0 39.984094 116.319236 2008-10-23 05:53:05 1 1 39.984198 116.319322 2008-10-23 05:53:06 1 2 39.984224 116.319402 2008-10-23 05:53:11 1 3 39.984211 116.319389 2008-10-23 05:53:16 1 4 39.984217 116.319422 2008-10-23 05:53:21 1 >>> plot_trajectories(move_df)
-
pymove.visualization.folium.
plot_trajectory_by_date
(move_data: PandasMoveDataFrame, start_date: str | date, end_date: str | date, id_: int | None = None, n_rows: int | None = None, lat_origin: float | None = None, lon_origin: float | None = None, zoom_start: float = 12, legend: bool = True, base_map: Map | None = None, tile: str = 'CartoDB positron', save_as_html: bool = False, color: str | list[str] | None = None, color_by_id: dict | None = None, filename: str = 'plot_trajectories_by_date.html') → Map[source]¶ Generate visualization of all trajectories with folium.
Parameters: - move_data (DataFrame) – Input trajectory data
- start_date (str) – Represents start date of time period.
- end_date (str) – Represents end date of time period.
- id (int, optional) – Trajectory id to plot, by default None
- n_rows (int, optional) – Represents number of data rows that are will plot, by default None.
- lat_origin (float, optional) – Represents the latitude which will be the center of the map. If not entered, the first data from the dataset is used, by default None.
- lon_origin (float, optional) – Represents the longitude which will be the center of the map. If not entered, the first data from the dataset is used, by default None.
- zoom_start (int, optional) – Initial zoom level for the map, by default 12.
- legend (boolean) – Whether to add a legend to the map, by default True
- base_map (folium.folium.Map, optional) –
Represents the folium map. If not informed, a new map is generated using the function create_base_map(), with the lat_origin, lon_origin
and zoom_start, by default None. - tile (str, optional) – Represents the map tiles, by default TILES[0]
- save_as_html (bool, optional) – Represents if want save this visualization in a new file .html, by default False.
- color (str, list, optional) – Represents line colors of visualization. Can be a single color name, a list of colors or a colormap name, by default None.
- color_by_id (dict, optional) – A dictionary where the key is the trajectory id and value is a color, by default None.
- filename (str, optional) – Represents the file name of new file .html, by default ‘plot_trajectories_by_date.html’.
Returns: a folium map with visualization
Return type: Map
Raises: KeyError
– If period value is not found in dataframeIndexError
– If there is no user with the id passed
Examples
>>> from pymove.visualization.folium import plot_trajectory_by_date >>> move_df.head() lat lon datetime id 0 39.984094 116.319236 2008-10-23 05:53:05 1 1 39.984198 116.319322 2008-10-23 05:53:06 1 2 39.984224 116.319402 2008-10-23 05:53:11 1 3 39.984211 116.319389 2008-10-23 05:53:16 1 4 39.984217 116.319422 2008-10-23 05:53:21 1 >>> plot_trajectory_by_date( >>> move_df, >>> start_date='2008-10-23 05:53:05', >>> end_date='2008-10-23 23:43:56' >>> )
-
pymove.visualization.folium.
plot_trajectory_by_day_week
(move_data: PandasMoveDataFrame, day_week: str, id_: int | None = None, n_rows: int | None = None, lat_origin: float | None = None, lon_origin: float | None = None, zoom_start: float = 12, legend: bool = True, base_map: Map | None = None, tile: str = 'CartoDB positron', save_as_html: bool = False, color: str | list[str] | None = None, color_by_id: dict | None = None, filename: str = 'plot_trajectories_by_day_week.html') → Map[source]¶ Generate visualization of all trajectories with folium.
Parameters: - move_data (DataFrame) – Input trajectory data
- day_week (str) – Day of the week
- id (int) – Trajectory id to plot, by default None
- n_rows (int, optional) – Represents number of data rows that are will plot, by default None.
- lat_origin (float, optional) – Represents the latitude which will be the center of the map. If not entered, the first data from the dataset is used, by default None.
- lon_origin (float, optional) – Represents the longitude which will be the center of the map. If not entered, the first data from the dataset is used, by default None.
- zoom_start (int, optional) – Initial zoom level for the map, by default 12.
- legend (boolean) – Whether to add a legend to the map, by default True
- base_map (folium.folium.Map, optional) –
Represents the folium map. If not informed, a new map is generated using the function create_base_map(), with the lat_origin, lon_origin
and zoom_start, by default None. - tile (str, optional) – Represents the map tiles, by default TILES[0]
- save_as_html (bool, optional) – Represents if want save this visualization in a new file .html, by default False.
- color (str, list, optional) – Represents line colors of visualization. Can be a single color name, a list of colors or a colormap name, by default None.
- color_by_id (dict, optional) – A dictionary where the key is the trajectory id and value is a color, by default None.
- filename (str, optional) – Represents the file name of new file .html, by default ‘plot_trajectories_by_day_week.html’.
Returns: a folium map with visualization
Return type: Map
Raises: KeyError
– If period value is not found in dataframeIndexError
– If there is no user with the id passed
Examples
>>> from pymove.visualization.folium import plot_trajectory_by_day_week >>> move_df.head() lat lon datetime id 0 39.984094 116.319236 2008-10-23 05:53:05 1 1 39.984198 116.319322 2008-10-23 05:53:06 1 2 39.984224 116.319402 2008-10-23 05:53:11 1 3 39.984211 116.319389 2008-10-23 05:53:16 1 4 39.984217 116.319422 2008-10-23 05:53:21 1 >>> plot_trajectory_by_day_week(move_df, day_week='Friday')
-
pymove.visualization.folium.
plot_trajectory_by_hour
(move_data: PandasMoveDataFrame, start_hour: str, end_hour: str, id_: int | None = None, n_rows: int | None = None, lat_origin: float | None = None, lon_origin: float | None = None, zoom_start: float = 12, legend: bool = True, base_map: Map | None = None, tile: str = 'CartoDB positron', save_as_html: bool = False, color: str | list[str] | None = None, color_by_id: dict | None = None, filename: str = 'plot_trajectories_by_hour.html') → Map[source]¶ Generate visualization of all trajectories with folium.
Parameters: - move_data (DataFrame) – Input trajectory data
- start_hour (str) – Represents start hour of time period.
- end_hour (str) – Represents end hour of time period.
- id (int, optional) – Trajectory id to plot, by default None
- n_rows (int, optional) – Represents number of data rows that are will plot, by default None.
- lat_origin (float, optional) – Represents the latitude which will be the center of the map. If not entered, the first data from the dataset is used, by default None.
- lon_origin (float, optional) – Represents the longitude which will be the center of the map. If not entered, the first data from the dataset is used, by default None.
- zoom_start (int, optional) – Initial zoom level for the map, by default 12.
- legend (boolean) – Whether to add a legend to the map, by default True
- base_map (folium.folium.Map, optional) –
Represents the folium map. If not informed, a new map is generated using the function create_base_map(), with the lat_origin, lon_origin
and zoom_start, by default None. - tile (str, optional) – Represents the map tiles, by default TILES[0]
- save_as_html (bool, optional) – Represents if want save this visualization in a new file .html, by default False.
- color (str, list, optional) – Represents line colors of visualization. Can be a single color name, a list of colors or a colormap name, by default None.
- color_by_id (dict, optional) – A dictionary where the key is the trajectory id and value is a color, by default None.
- filename (str, optional) – Represents the file name of new file .html, by default ‘plot_trajectories_by_hour.html’.
Returns: a folium map with visualization
Return type: Map
Raises: KeyError
– If period value is not found in dataframeIndexError
– If there is no user with the id passed
Examples
>>> from pymove.visualization.folium import plot_trajectory_by_hour >>> move_df.head() lat lon datetime id 0 39.984094 116.319236 2008-10-23 05:53:05 1 1 39.984198 116.319322 2008-10-23 05:53:06 1 2 39.984224 116.319402 2008-10-23 05:53:11 1 3 39.984211 116.319389 2008-10-23 05:53:16 1 4 39.984217 116.319422 2008-10-23 05:53:21 1 >>> plot_trajectory_by_hour(move_df, start_hour=4, end_hour=6)
-
pymove.visualization.folium.
plot_trajectory_by_id
(move_data: DataFrame, id_: int, n_rows: int | None = None, lat_origin: float | None = None, lon_origin: float | None = None, zoom_start: float = 12, legend: bool = True, base_map: Map | None = None, tile: str = 'CartoDB positron', save_as_html: bool = False, color: str | list[str] | None = None, filename: str = 'plot_trajectories.html') → Map[source]¶ Generate visualization of all trajectories with folium.
Parameters: - move_data (DataFrame) – Input trajectory data
- id (int) – Trajectory id to plot
- n_rows (int, optional) – Represents number of data rows that are will plot, by default None.
- lat_origin (float, optional) – Represents the latitude which will be the center of the map. If not entered, the first data from the dataset is used, by default None.
- lon_origin (float, optional) – Represents the longitude which will be the center of the map. If not entered, the first data from the dataset is used, by default None.
- zoom_start (int, optional) – Initial zoom level for the map, by default 12.
- legend (boolean) – Whether to add a legend to the map, by default True
- base_map (folium.folium.Map, optional) –
Represents the folium map. If not informed, a new map is generated using the function create_base_map(), with the lat_origin, lon_origin
and zoom_start, by default None. - tile (str, optional) – Represents the map tiles, by default TILES[0]
- save_as_html (bool, optional) – Represents if want save this visualization in a new file .html, by default False.
- color (str, list, optional) – Represents line colors of visualization. Can be a single color name, a list of colors or a colormap name, by default None.
- filename (str, optional) – Represents the file name of new file .html, by default ‘plot_trajectory_by_id.html’.
Returns: a folium map with visualization
Return type: Map
Raises: IndexError
– If there is no user with the id passedExamples
>>> from pymove.visualization.folium import plot_trajectory_by_id >>> move_df.head() lat lon datetime id 0 39.984094 116.319236 2008-10-23 05:53:05 1 1 39.984198 116.319322 2008-10-23 05:53:06 1 2 39.984224 116.319402 2008-10-23 05:53:11 1 3 39.984211 116.319389 2008-10-23 05:53:16 2 4 39.984217 116.319422 2008-10-23 05:53:21 2 >>> plot_trajectory_by_id(move_df, id_=1)
-
pymove.visualization.folium.
plot_trajectory_by_period
(move_data: PandasMoveDataFrame, period: str, id_: int | None = None, n_rows: int | None = None, lat_origin: float | None = None, lon_origin: float | None = None, zoom_start: float = 12, legend: bool = True, base_map: Map | None = None, tile: str = 'CartoDB positron', save_as_html: bool = False, color: str | list[str] | None = None, color_by_id: dict | None = None, filename: str = 'plot_trajectories_by_period.html') → Map[source]¶ Generate visualization of all trajectories with folium.
Parameters: - move_data (DataFrame) – Input trajectory data
- period (str) – Period of the day
- id (int) – Trajectory id to plot, by default None
- n_rows (int, optional) – Represents number of data rows that are will plot, by default None.
- lat_origin (float, optional) – Represents the latitude which will be the center of the map. If not entered, the first data from the dataset is used, by default None.
- lon_origin (float, optional) – Represents the longitude which will be the center of the map. If not entered, the first data from the dataset is used, by default None.
- zoom_start (int, optional) – Initial zoom level for the map, by default 12.
- legend (boolean) – Whether to add a legend to the map, by default True
- base_map (folium.folium.Map, optional) –
Represents the folium map. If not informed, a new map is generated using the function create_base_map(), with the lat_origin, lon_origin
and zoom_start, by default None. - tile (str, optional) – Represents the map tiles, by default TILES[0]
- save_as_html (bool, optional) – Represents if want save this visualization in a new file .html, by default False.
- color (str, list, optional) – Represents line colors of visualization. Can be a single color name, a list of colors or a colormap name, by default None.
- color_by_id (dict, optional) – A dictionary where the key is the trajectory id and value is a color, by default None.
- filename (str, optional) – Represents the file name of new file .html, by default ‘plot_trajectories_by_period.html’.
Returns: a folium map with visualization
Return type: Map
Raises: KeyError
– If period value is not found in dataframeIndexError
– If there is no user with the id passed
Examples
>>> from pymove.visualization.folium import plot_trajectory_by_period >>> move_df.head() lat lon datetime id 0 39.984094 116.319236 2008-10-23 05:53:05 1 1 39.984198 116.319322 2008-10-23 05:53:06 1 2 39.984224 116.319402 2008-10-23 05:53:11 1 3 39.984211 116.319389 2008-10-23 05:53:16 1 4 39.984217 116.319422 2008-10-23 05:53:21 1 >>> plot_trajectory_by_period(move_df, period='Early morning')
-
pymove.visualization.folium.
save_map
(move_data: DataFrame, filename: str, tiles: str = 'CartoDB positron', label_id: str = 'id', cmap: str = 'Set1', return_map: bool = False) → Map | None[source]¶ Save a visualization in a map in a new file.
Parameters: - move_data (DataFrame) – Input trajectory data
- filename (Text) – Represents the filename path
- tiles (str, optional) – Represents the type_ of tile that will be used on the map, by default TILES[0]
- label_id (str, optional) – Represents column name of trajectory id, by default TRAJ_ID
- cmap (str, optional) – Color map to use, by default ‘Set1’
- return_map (bool, optional) – Represents the Colormap, by default False
Returns: folium map or None
Return type: Map
Examples
>>> from pymove.visualization.folium import save_map >>> move_df.head() lat lon datetime id 0 39.984094 116.319236 2008-10-23 05:53:05 1 1 39.984198 116.319322 2008-10-23 05:53:06 1 2 39.984224 116.319402 2008-10-23 05:53:11 1 3 39.984211 116.319389 2008-10-23 05:53:16 1 4 39.984217 116.319422 2008-10-23 05:53:21 1 >>> save_map(df, filename='test.map')
pymove.visualization.matplotlib module¶
Matplolib operations.
show_object_id_by_date, plot_trajectories, plot_trajectory_by_id, plot_grid_polygons, plot_all_features plot_coords, plot_bounds, plot_line
-
pymove.visualization.matplotlib.
plot_all_features
(move_data: DataFrame, dtype: Callable = <class 'float'>, figsize: tuple[float, float] = (21, 15), return_fig: bool = False, save_fig: bool = False, name: str = 'features.png') → figure | None[source]¶ Generate a visualization for each columns that type is equal dtype.
Parameters: - move_data (dataframe) – Dataframe with trajectories
- dtype (callable, optional) – Represents column type, by default np.float64
- figsize (tuple(float, float), optional) – Represents dimensions of figure, by default (21, 15)
- return_fig (bool, optional) – Represents whether or not to return the generated picture, by default False
- save_fig (bool, optional) – Represents whether or not to save the generated picture, by default False
- name (str, optional) – Represents name of a file, by default ‘features.png’
Returns: The generated picture or None
Return type: figure
Raises: AttributeError
– If there are no columns with the specified typeExamples
>>> from pymove.visualization.matplotlib import plot_all_features >>> move_df.head() lat lon datetime id 0 39.984094 116.319236 2008-10-23 05:53:05 1 1 39.984198 116.319322 2008-10-23 05:53:06 1 2 39.984224 116.319402 2008-10-23 05:53:11 1 3 39.984211 116.319389 2008-10-23 05:53:16 2 4 39.984217 116.319422 2008-10-23 05:53:21 2 >>> plot_all_features(move_df)
-
pymove.visualization.matplotlib.
plot_bounds
(ax: axes, ob: LineString | MultiLineString, color='b')[source]¶ Plot the limits of geometric object.
Parameters: - ax (axes) – Single axes object
- ob (LineString or MultiLineString) – Geometric object formed by lines.
- color (str, optional) – Sets the geometric object color, by default ‘b’
Example
>>> from pymove.visualization.matplotlib import plot_bounds >>> import matplotlib.pyplot as plt >>> bounds = LineString([(1, 1), (1, 2), (2, 2), (2, 3)]) >>> _, ax = plt.subplots(figsize=(21, 9)) >>> plot_bounds(ax, bounds)
-
pymove.visualization.matplotlib.
plot_coords
(ax: matplotlib.pyplot.axes, ob: shapely.geometry.base.BaseGeometry, color: str = 'r')[source]¶ Plot the coordinates of each point of the object in a 2D chart.
Parameters: - ax (axes) – Single axes object
- ob (geometry object) – Any geometric object
- color (str, optional) – Sets the geometric object color, by default ‘r’
Example
>>> from pymove.visualization.matplotlib import plot_coords >>> import matplotlib.pyplot as plt >>> coords = LineString([(1, 1), (1, 2), (2, 2), (2, 3)]) >>> _, ax = plt.subplots(figsize=(21, 9)) >>> plot_coords(ax, coords)
-
pymove.visualization.matplotlib.
plot_grid_polygons
(data: DataFrame, grid: Grid | None = None, markersize: float = 10, linewidth: float = 2, figsize: tuple[int, int] = (10, 10), return_fig: bool = False, save_fig: bool = False, name: str = 'grid.png') → figure | None[source]¶ Generate a visualization with grid polygons.
Parameters: - data (DataFrame) – Input trajectory data
- markersize (float, optional) – Represents visualization size marker, by default 10
- linewidth (float, optional) – Represents visualization size line, by default 2
- figsize (tuple(int, int), optional) –
- Represents the size (float: width, float: height) of a figure,
- by default (10, 10)
- return_fig (bool, optional) – Represents whether or not to save the generated picture, by default False
- save_fig (bool, optional) – Wether to save the figure, by default False
- name (str, optional) – Represents name of a file, by default ‘grid.png’
Returns: The generated picture or None
Return type: figure
Raises: If the dataframe does not contains the POLYGON feature
- IndexError
- If there is no user with the id passed
-
pymove.visualization.matplotlib.
plot_line
(ax: matplotlib.pyplot.axes, ob: shapely.geometry.linestring.LineString, color: str = 'r', alpha: float = 0.7, linewidth: float = 3, solid_capstyle: str = 'round', zorder: float = 2)[source]¶ Plot a LineString.
Parameters: - ax (axes) – Single axes object
- ob (LineString) – Sequence of points.
- color (str, optional) – Sets the line color, by default ‘r’
- alpha (float, optional) – Defines the opacity of the line, by default 0.7
- linewidth (float, optional) – Defines the line thickness, by default 3
- solid_capstyle (str, optional) – Defines the style of the ends of the line, by default ‘round’
- zorder (float, optional) – Determines the default drawing order for the axes, by default 2
Example
>>> from pymove.visualization.matplotlib import plot_line >>> import matplotlib.pyplot as plt >>> line = LineString([(1, 1), (1, 2), (2, 2), (2, 3)]) >>> _, ax = plt.subplots(figsize=(21, 9)) >>> plot_line(ax, line)
-
pymove.visualization.matplotlib.
plot_trajectories
(move_data: DataFrame, markers: str = 'o', markersize: float = 12, figsize: tuple[float, float] = (10, 10), return_fig: bool = False, save_fig: bool = False, name: str = 'trajectories.png') → figure | None[source]¶ Generate a visualization that show trajectories.
Parameters: - move_data (dataframe) – Dataframe with trajectories
- markers (str, optional) – Represents visualization type marker, by default ‘o’
- markersize (float, optional) – Represents visualization size marker, by default 12
- figsize (tuple(float, float), optional) – Represents dimensions of figure, by default (10, 10)
- return_fig (bool, optional) – Represents whether or not to return the generated picture, by default False
- save_fig (bool, optional) – Represents whether or not to save the generated picture, by default False
- name (str, optional) – Represents name of a file, by default ‘trajectories.png’
Returns: The generated picture or None
Return type: figure
Examples
>>> from pymove.visualization.matplotlib import plot_trajectories >>> move_df.head() lat lon datetime id 0 39.984094 116.319236 2008-10-23 05:53:05 1 1 39.984198 116.319322 2008-10-23 05:53:06 1 2 39.984224 116.319402 2008-10-23 05:53:11 1 3 39.984211 116.319389 2008-10-23 05:53:16 2 4 39.984217 116.319422 2008-10-23 05:53:21 2 >>> plot_trajectories(move_df)
-
pymove.visualization.matplotlib.
plot_trajectory_by_id
(move_data: DataFrame, id_: int | str, label: str = 'id', feature: str | None = None, value: Any | None = None, linewidth: float = 3, markersize: float = 20, figsize: tuple[float, float] = (10, 10), return_fig: bool = False, save_fig: bool = False, name: str | None = None) → figure | None[source]¶ Generate a visualization that shows a trajectory with the specified tid.
Parameters: - move_data (dataframe) – Dataframe with trajectories
- id (int, str) – Represents the trajectory tid
- label (str, optional) – Feature with trajectories tids, by default TID
- feature (str, optional) – Name of the feature to highlight on plot, by default None
- value (any, optional) – Value of the feature to be highlighted as green marker, by default None
- linewidth (float, optional) – Represents visualization size line, by default 2
- markersize (float, optional) – Represents visualization size marker, by default 20
- figsize (tuple(float, float), optional) – Represents dimensions of figure, by default (10, 10)
- return_fig (bool, optional) – Represents whether or not to return the generated picture, by default False
- save_fig (bool, optional) – Represents whether or not to save the generated picture, by default False
- name (str, optional) – Represents name of a file, by default None
Returns: Trajectory with the specified tid. The generated picture.
Return type: PandasMoveDataFrame’, figure
Raises: KeyError
– If the dataframe does not contains the TID featureIndexError
– If there is no trajectory with the tid passed
Examples
>>> from pymove.visualization.matplotlib import plot_traj_by_id >>> move_df lat lon datetime id 0 39.984094 116.319236 2008-10-23 05:53:05 1 1 39.984198 116.319322 2008-10-23 05:53:06 1 2 39.984224 116.319402 2008-10-23 05:53:11 1 3 39.984211 116.319389 2008-10-23 05:53:16 2 4 39.984217 116.319422 2008-10-23 05:53:21 2 >>> plot_traj_by_id(move_df_3, 1, label='id) >>> plot_traj_by_id(move_df_3, 2, label='id)
-
pymove.visualization.matplotlib.
show_object_id_by_date
(move_data: 'PandasMoveDataFrame' | 'DaskMoveDataFrame', kind: list | None = None, figsize: tuple[float, float] = (21, 9), return_fig: bool = False, save_fig: bool = False, name: str = 'shot_points_by_date.png') → figure | None[source]¶ Generates four visualizations based on datetime feature.
- Bar chart trajectories by day periods
- Bar chart trajectories day of the week
- Line chart trajectory by date
- Line chart of trajectory by hours of the day.
Parameters: - move_data (pymove.core.MoveDataFrameAbstract subclass.) – Input trajectory data.
- kind (list, optional) – Determines the kinds of each plot, by default None
- figsize (tuple, optional) – Represents dimensions of figure, by default (21,9).
- return_fig (bool, optional) – Represents whether or not to save the generated picture, by default False.
- save_fig (bool, optional) – Represents whether or not to save the generated picture, by default False.
- name (String, optional) – Represents name of a file, by default ‘shot_points_by_date.png’.
Returns: The generated picture or None
Return type: figure
References
https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.plot.html
Examples
>>> from pymove.visualization.matplotlib import show_object_id_by_date >>> move_df.head() lat lon datetime id 0 39.984094 116.319236 2008-10-23 05:53:05 1 1 39.984198 116.319322 2008-10-23 05:53:06 1 2 39.984224 116.319402 2008-10-23 05:53:11 1 3 39.984211 116.319389 2008-10-23 05:53:16 2 4 39.984217 116.319422 2008-10-23 05:53:21 2 >>> show_object_id_by_date(move_df)