tracktable.render.backends.folium_backend module¶
Note
This module is used by render_trajectories and render_heatmap and shouldn’t be accessed directly.
Module contents¶
tracktable.render.folium - render trajectories in using the folium backend
- tracktable.render.backends.folium_backend.bounding_box_for_folium(trajectories)[source]¶
Translates a computed bounding box to the format needed by folium
- tracktable.render.backends.folium_backend.render_airports_and_ports(map_canvas, draw_airports=False, draw_ports=False, airport_color='red', port_color='blue', airport_dot_size=1, port_dot_size=1, use_shapefile=False, use_markers=False, popup_width=250, airport_list=[], port_list=[], airport_bounding_box=None, port_country=None, port_water_body=None, port_wpi_region=None, port_bounding_box=None, port_and_country_seperate=False, **kwargs)[source]¶
Renders airports and/or ports to the folium map
- Parameters:
map_canvas (folium map object) – Canvas to draw the airports/ports on
- Keyword Arguments:
draw_airports (bool) – Whether or not to draw airports (Default: False)
draw_ports (bool) – Whether or not to draw ports (Default: False)
or (port_color (name of standard color as string, hex color string) – matplotlib color object): Color of the airport dot or marker (Default: ‘red’)
or – matplotlib color object): Color of the port dot or marker (Default: ‘blue’)
airport_dot_size (float) – Radius of a airport dot (Default: 1)
port_dot_size (float) – radius of a port dot (Default: 1)
use_markers (bool) – Bool for using marker object instead of dots for airports and prots, used for Folium rendering only. (Default: False)
popup_width (int) – Size of the popup window that displays airport/port information, used for Folium rendering only (Default: 250)
airport_list (list(str)) – IATA code of airports to render onto the map (Default: [])
port_list (list(str)) – Name or WPI index number of ports to render onto the map (Default: [])
airport_bounding_box (BoundingBox or tuple/list of points) – bounding box for rendering airports within. (Default: None)
port_bounding_box (BoundingBox or tuple/list of points) – bounding box for rendering ports within. (Default: None)
port_country (str) – Name of country to render ports in. (Default: None)
port_water_body (str) – Name of body of water to render ports on. (Default: None)
port_wpi_region (str) – Name of WPI region to render ports in. (Default: None)
port_and_country_seperate (bool) – Bool for searching the ports database for a port and not considering it’s country to see if it’s rendered. i.e. You want to render a port in the U.K. while rendering all ports in Japan. (Default: False)
- Returns:
No return value
- tracktable.render.backends.folium_backend.render_heatmap(points, trajectories=None, weights=None, color_map='viridis', tiles='cartodbdark_matter', attr='.', crs='EPSG3857', show=False, save=False, filename='', show_scale=True, max_zoom=22, draw_airports=False, draw_ports=False, airport_color='red', port_color='blue', airport_dot_size=1, port_dot_size=1, use_shapefile=False, use_markers=False, popup_width=250, airport_list=[], port_list=[], airport_bounding_box=None, port_country=None, port_water_body=None, port_wpi_region=None, port_bounding_box=None, port_and_country_seperate=False, prefer_canvas=False, draw_shorelines=False, draw_rivers=False, draw_borders=False, shoreline_color='red', river_color='blue', border_color='green', shoreline_fill_polygon=True, shoreline_fill_color='red', shoreline_list=[], river_list=[], border_list=[], shoreline_bounding_box=None, river_bounding_box=None, border_bounding_box=None, shoreline_resolution='low', shoreline_level='L1', river_resolution='low', river_level='L01', border_resolution='low', border_level='L1', **kwargs)[source]¶
Creates an interactive heatmap visualization using the folium backend
For documentation on the parameters, please see render_heatmap
- tracktable.render.backends.folium_backend.render_point(current_point, point_popup_properties, coord, point_radius, point_color, map_canvas)[source]¶
Renders a point to the folium map
- Parameters:
current_point (point) – Current point of the trajectory
point_popup_properties (list) – Point properties
coord (tuple) – Coordinates to render point
point_radius (int) – Size of the point to render
point_color (str) – Color of the point to render
map (Basemap) – Folium map
- Returns:
No return value
- tracktable.render.backends.folium_backend.render_shorelines_rivers_borders(map_canvas, draw_shorelines=False, draw_rivers=False, draw_borders=False, shoreline_color='red', river_color='blue', border_color='green', shoreline_fill_polygon=True, shoreline_fill_color='red', popup_width=375, shoreline_list=[], river_list=[], border_list=[], shoreline_bounding_box=None, river_bounding_box=None, border_bounding_box=None, shoreline_resolution='low', shoreline_level='L1', river_resolution='low', river_level='L01', border_resolution='low', border_level='L1', display_polygon_tooltip=True, **kwargs)[source]¶
Renders shorelines, rivers and/or borders to the folium map
- Parameters:
map_canvas (folium map object) – Canvas to draw the shorelines/rivers/borders on
- Keyword Arguments:
draw_shorelines (bool) – Whether or not to draw shorelines (Default: False)
draw_rivers (bool) – Whether or not to draw rivers (Default: False)
draw_borders (bool) – Whether or not to draw borders (Default: False)
or (shoreline_fill_color (name of standard color as string, hex color string) – matplotlib color object): Color of the shoreline (Default: ‘red’)
or – matplotlib color object): Color of the river (Default: ‘blue’)
or – matplotlib color object): Color of the border (Default: ‘green’)
shoreline_fill_polygon (bool) – Whether or not to fill in the inside of the shoreline polygon (Default: True)
or – matplotlib color object): Fill color of the shoreline (Default: ‘red’)
popup_width (int) – Size of the popup window that displays airport/port information, used for Folium rendering only (Default: 375)
shoreline_list (list(int)) – GSHHS index number of the shoreline polygons to render (Default: [])
river_list (list(int)) – WDBII index number of the river polygons to render (Default: [])
border_list (list(int)) – WDBII index number of the border polygons to render (Default: [])
shoreline_bounding_box (BoundingBox) – bounding box for rendering shorelines within. (Default: None)
river_bounding_box (BoundingBox) – bounding box for rendering rivers within. (Default: None)
border_bounding_box (BoundingBox) – bounding box for rendering borders within. (Default: None)
shoreline_resolution (string) – Resolution of the shapes to pull from the shapefile. (Default: “low”)
shoreline_level (string) – See the docstring for build_shoreline_dict() for more information about levels. (Default: “L1”)
river_resolution (string) – Resolution of the shapes to pull from the shapefile. (Default: “low”)
river_level (string) – See the docstring for build_river_dict() for more information about levels. (Default: “L01”)
border_resolution (string) – Resolution of the shapes to pull from the shapefile. (Default: “low”)
border_level (string) – See the docstring for build_border_dict() for more information about levels. (Default: “L1”)
display_polygon_tooltip (bool) – Whether or not to display the tooltip when hovering over a polygon. (Default: True)
- Returns:
No return value
- tracktable.render.backends.folium_backend.render_trajectories(trajectories, map_canvas=None, obj_ids=[], map_bbox=None, show_lines=True, gradient_hue=None, color_map='', line_color='', linewidth=2.4, show_points=False, point_size=0.6, point_color='', show_dot=True, dot_size=0.7, dot_color='white', trajectory_scalar_generator=<function path_length_fraction_generator>, trajectory_linewidth_generator=None, color_scale=<matplotlib.colors.Normalize object>, show=False, save=False, filename='', tiles='cartodbdark_matter', attr='.', crs='EPSG3857', point_popup_properties=[], show_distance_geometry=False, distance_geometry_depth=4, zoom_frac=[0, 1], show_scale=True, max_zoom=22, fast=False, animate=False, anim_display_update_interval=datetime.timedelta(microseconds=200000), anim_timestamp_update_step=datetime.timedelta(seconds=60), anim_trail_duration=None, anim_loop=True, draw_airports=False, draw_ports=False, airport_color='red', port_color='blue', airport_dot_size=1, port_dot_size=1, use_shapefile=False, use_markers=False, popup_width=250, airport_list=[], port_list=[], airport_bounding_box=None, port_country=None, port_water_body=None, port_wpi_region=None, port_bounding_box=None, port_and_country_seperate=False, prefer_canvas=False, draw_shorelines=False, draw_rivers=False, draw_borders=False, shoreline_color='red', river_color='blue', border_color='green', shoreline_fill_polygon=True, shoreline_fill_color='red', shoreline_list=[], river_list=[], border_list=[], shoreline_bounding_box=None, river_bounding_box=None, border_bounding_box=None, shoreline_resolution='low', shoreline_level='L1', river_resolution='low', river_level='L01', border_resolution='low', border_level='L1', **kwargs)[source]¶
Render a list of trajectories using the folium backend
For documentation on the parameters, please see render_trajectories
- tracktable.render.backends.folium_backend.timedelta_to_iso8601_duration(td: timedelta) str[source]¶
Convert a datetime.timedelta to ISO8601 Duration format
This function converts a duration specified as a
datetime.timedeltato ISO 8601 string format. Fractional seconds will be rounded to the nearest second.- Parameters:
td (datetime.timedelta) – Interval to convert
- Returns:
Duration represented as a string in ISO8601 format (without fractional seconds)