tracktable.render.render_trajectories module¶
Module contents¶
tracktable.render.render_trajectories - render trajectories in python
This is a set of function that intend to allow user-friendly rendering of trajectories. A user should be able to simply use the function render_trajectories(trajs) passing a single parameter that is a list of trajectories and get a rendering of those trajectories, whether running as an interactive map inside of a noetbook or from the command line and saved as a static image to a file.
In addition render_trajectories supports many parameters to enable specifying a myriad of options for rendering the trajectories, including allowing users to explicitly specify the rendering backend.
- tracktable.render.render_trajectories.render_trajectories(trajectories, backend='', simplify_traj=False, simplify_tol=0.0001, **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
trajectories (single Tracktable trajectory or list of trajectories) – Trajectories 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.
simplify_traj (bool) – Simplify trajectories prior to rendering them
simplify_tol (float) – Tolerance to use when simplifying trajectories, default is 0.0001
map_canvas (map object for given backend) – rather than create a new map, append to this given map
obj_ids (str or list of str) – only display trajecteories whose object id matches the given string or a string from the given list of strings.
map_bbox ([minLon, minLat, maxLon, maxLat]) – bounding box for custom map extent. By default automatically set to make all trajectories visible.
show_lines (bool) – whether or not to show the line segments of the trajecotry (Default: True)
gradient_hue (float or list of floats) – hue or list of hues (one per trajectory) to be used in definig the gradient color map (dark to light) for the trajectories. Only used if line_color and color_map are not used (set to ‘’). If line_color, color_map and gradient_hue are all unset the default behavior is to set the gradient_hue based on a hash of the object_id
matplotlib (color_map (name of standard colormap as string or) – color_map object or list of either): The color map to use in rendering the segments of each trajectory. Overrides the gradient_hue value. Can be a list of color map objects or a list of matplotlib color map name strings the same length the length of the list of trajectories. Only used if line_color is not used (set to ‘’).
string (point_color = (name of standard color as string, hex color) – or matplotlib color object, or list of any of these): The single color to use for all the segments in each trajectory. Overrides color_map and gradient_hue values. Can be a list of matplotlib color name strings, hex color strings or matplotlib color objects the same length as the length of the list of trajectories.
linewidth (float) – Width of the trajectory segments. (Default: folium 2.5, cartopy 2)
show_points (bool) – whether or not to show the points along the trajecotry (Default: False)
point_size (float) – radius of the points along the path (Default: folium 0.6, cartopy 10.0)
string – or matplotlib color object, or list of any of these): The single color to use for all the points in each trajectory. Can be a list of matplotlib color name strings, hex color strings or matplotlib color objects the same length as the length of the list of trajectories. If not specified, the color matches the segment incident at the point.
dot_size (float) – radius of a dot drawn at the latest point of each trajectory (Default: folium 0.7, cartopy 10.0)
or (dot_color (name of standard color as string, hex color string) – matplotlib color object): Color of spot that will be drawn at the latest point of each trajecctory (Default: ‘white’)
trajectory_scalar_generator (function) – Function to generate scalars for a trajectory (Default: path_length_fraction_generator)
trajectory_linewidth_generator (function) – Function to generate path widths for a trajectory (Default: None)
color_scale (matplotlib.colors.Normalize() or LogNorm()) – Linear or logarithmic scale (Default: matplotlib.colors.Normalize(vmin=0, vmax=1))
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 (Cartopy CRS) – Cartopy CRS projection object (optional), used for Cartopy rendering only. (Default: None)
transform – Matplotlib axes to render into, used for Cartopy rendering only. (Default: cartopy.crs.PlateCarree())
tiles (str) – Map tiles to use during image generation, the name or server url can be used. Options include OpenStreetMaps, StamenTerrain, StamenToner, StamenWatercolor, CartoDBPositron CartoDBDark_Matter, used for Folium rendering only. (Default: ‘cartodbdark_matter’)
attr (str) – Map tile attribution; only required if passing custom tile URL, used for Folium rendering only. (Default: “.”)
crs (str) – Defines coordinate reference systems for projecting geographical points into pixel (screen) coordinates and back, used for Folium rendering only. (Default: “EPSG3857”)
point_popup_properties (list) – Point properties, used for Folium rendering only.
show_distance_geometry (bool) – Boolean to enable displaying distance geometry for a given trajectory, used for Folium rendering only. (Default: False)
distance_geometry_depth (int) – Level of distance geometry to display, used for Folium rendering only. (Default: 4)
show_scale (bool) – Boolean to draw the distance scale of the map, used for Folium rendering only. (Default: True)
max_zoom (int) – Maximum allowed zoom level for the tile layer that is created, used for Folium rendering only. (Default: 22)
fast (bool) – Bool for reduced/faster processing of the folium map, used for Folium rendering only. (Default: False)
- tracktable.render.render_trajectories.render_trajectories_for_print(trajectories, filename, land_fill_color='white', water_fill_color='#EEEEEE', color_map='viridis', dot_color='grey', linewidth=1.5, figsize=(6, 4), save=True, **kwargs)[source]¶
Render a list of trajectories with print-friendly defaults
This function will render a list of trajectories using Cartopy in a way this is more appropriate for use in printed media.
- tracktable.render.render_trajectories.render_trajectories_for_print_using_tiles(trajectories, filename, color_map='viridis', dot_color='grey', linewidth=1.5, figsize=(6, 4), save=True, tiles='https://basemaps.cartocdn.com/rastertiles/light_all/{z}/{x}/{y}.png', fill_land=False, fill_water=False, draw_coastlines=False, draw_countries=False, draw_states=False, **kwargs)[source]¶
- Render a list of trajectories with print-friendly defaults
but using tiles as the basemap.
This function will render a list of trajectories using Cartopy in a way this is more appropriate for use in printed media.
- tracktable.render.render_trajectories.render_trajectories_separate(trajectories, backend='', **kwargs)[source]¶
Render a list of trajectories such that each trajectory is rendered separately in its own map. See render_trajectories for parameters
- Parameters
trajectories (Tracktable trajectory or list of trajectory objects) – List of trajectories to render
- Keyword Arguments
- Returns
No return value