tracktable.render.render_heatmap module¶
Module contents¶
tracktable.render.heatmaps - render heatmaps in python
This is a set of functions that intend to allow user-friendly rendering of heatmaps. A user should be able to simply use the function render_heatmap(points) passing a single parameter that is a list of points and get a rendering of those points, whether running as an interactive map inside of a notebook or from the command line and saved as a static image to a file.
- tracktable.render.render_heatmap.render_heatmap(points, backend='', trajectories=None, **kwargs)[source]¶
Render a list of trajectories interactively or as a static image
This function will render a list of trajectories using Folium (for interactive display) if you are in a Jupyter notebook or using Cartopy (for a static image) if you are running from a script.
- Parameters:
points (single points or list of points) – Points to render
- Keyword Arguments:
backend (str) – Which back end to use. This can be ‘folium’ to force Folium interactive rendering or ‘cartopy’ to force static images. Defaults to None, which lets the renderer select automatically.
trajectories (Trajectory) – list of trajectories corresponding to the points, render trajectories if provided. (Default: None)
simplify_traj (bool) – Simplify trajectories prior to rendering them (Default: False)
simplify_tol (float) – Tolerance to use when simplifying trajectories (Default: 0.0001)
weights – (list) list of weights associated with each point (Default: None)
color_map – (str) name of matplotlib colormap to use for the heatmap (Default: ‘viridis’)
tiles (str) – name of map tiling to use (Default: ‘cartodbdark_matter’)
attr (str) – folium specific parameter (Default: ‘.’)
crs (str) – folium specific parameter (Default: “EPSG3857”)
show (bool) – whether or not to show the result (if possible) (default: True) if saving to a file, might not want to view.
save (bool) – whether or not to save the result to a file. For folium the results can be saved to an html file. For cartopy the results can be saved as an image. If no filename is given, a default filename including the timestamp is used. (default: False)
filename (str) – Path and filename to save the results to, if save is set to True. If no filename is given, a default filename including the timestamp is used.
map_projection (GeoAxes) – Map to render onto
point_source (iterable) – Sequence of 2D points. This will be traversed only once.
bounding_box (point2d) – Bounding box of area to generate histogram
bin_size (int) – Boundary size for bins (Default: 1)
colormap (str or Colormap) – Colors to use for histogram (Default: ‘gist_heat’)
colorscale (matplotlib.colors.Normalize or subclass) – Mapping from bin counts to color. Useful values are matplotlib.colors.Normalize() and matplotlib.colors.LogNorm(). (Default: matplotlib.colors.Normalize())
zorder (int) – Image priority for rendering. Higher values will be rendered on top of actors with lower z-order. (Default: 10)
draw_cities (bool) – Render the cities within the given bounding box. (Default: False)
draw_airports (bool) – Whether or not to draw airports (Default: False)
draw_all_airports (bool) – Render all of the ports in the map_bbox, used for Cartopy rendering only. (Default: False)
airport_list (list(str)) – IATA code of airports to render onto the map (Default: [])
airport_bounding_box (BoundingBox or tuple/list of points) – Bounding box for rendering airports within. (Default: None)
or (shoreline_fill_color (name of standard color as string, hex color string) – matplotlib color object): Color of the airport dot or marker (Default: ‘red’)
airport_label_size (int) – Size (in points) for airport name labels, used for Cartopy rendering only. (Default: 12)
airport_dot_size (float) – Radius of a airport dot (Default: folium 1, cartopy 2)
airport_label_color (str) – Color name or hex string for airport names, used for Cartopy rendering only. (Default: ‘white’)
airport_zorder (int) – Color name or hex string for airport names, used for Cartopy rendering only. (Default: 6)
draw_ports (bool) – Whether or not to draw ports (Default: False)
draw_all_ports (bool) – Render all of the ports in the map_bbox, used for Cartopy rendering only. (Default: False)
port_list (list(str)) – Name or WPI index number of ports to render onto the map (Default: [])
or – matplotlib color object): Color of the port dot or marker (Default: ‘blue’)
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_bounding_box (BoundingBox or tuple/list of points) – Bounding box for rendering ports within. (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)
port_label_size (int) – Size (in points) for port name labels, used for Cartopy rendering only. (Default: 12)
port_dot_size (float) – radius of a port dot (Default: folium 1, cartopy 2)
port_label_color (str) – Color name or hex string for port names, used for Cartopy rendering only. (Default: ‘white’)
port_zorder (int) – Color name or hex string for port names, used for Cartopy rendering only. (Default: 6)
draw_arrows (bool) – Whether or not to draw arrows from airport/port labels to dots (Default: True)
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 – 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, used for folium rendering only (Default: True)