tracktable.render.map_processing.common_processing module¶
Module contents¶
tracktable.render.common_processing - Collection of functions that are commonly used across all of the rendering backends
- tracktable.render.map_processing.common_processing.common_processing(trajectories, obj_ids, line_color, color_map, gradient_hue)[source]¶
Common processing functionality
- Parameters
trajectories (list) – List of Trajectories
obj_ids (list) – List of IDs
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.
string – 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.
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.
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
- Returns
trajectories, line_color, color_map and gradient_hue
- tracktable.render.map_processing.common_processing.draw_density_array(density, map_projection, bounding_box, colormap=None, colorscale=None, zorder=10, axes=None)[source]¶
Render a histogram for the given map projection.
- Parameters
density (iterable) – Density array that will be drawn onto the map
map_projection (Basemap) – Map to render onto
bounding_box (point2d) – Bounding box of area to gdraw the
- Keyword Arguments
colormap (str or Colormap) – Colors to use for histogram (Default: None)
colorscale (matplotlib.colors.Normalize or subclass) – Mapping from bin counts to color. Useful values are matplotlib.colors.Normalize() and matplotlib.colors.LogNorm(). (Default: None)
zorder (int) – Image priority for rendering. Higher values will be rendered on top of actors with lower z-order. (Default: 10)
axes (matplotlib.axes.Axes) – Axes to render into. Defaults to “current axes” as defined by Matplotlib. (Default:None)
- Returns
The density rendered onto the map.
- tracktable.render.map_processing.common_processing.hash_short_md5(string)[source]¶
- Given any string, returns a number between 0 and 1. The same
number is always returned given the same string. Internally uses hashlib.md5, but only uses the first quarter of the full hash
- Parameters
string (str) – String to be hashed
- Returns
0 or 1
- tracktable.render.map_processing.common_processing.in_notebook()[source]¶
Returns True if run within a Jupyter notebook, and false otherwise
- tracktable.render.map_processing.common_processing.load_density_array(infile)[source]¶
Load the density array from a file.
- Parameters
infile (str) – Filename for input
- Returns
The density array in the file.
- tracktable.render.map_processing.common_processing.path_length_fraction_generator(trajectory)[source]¶
Generator to produce path length fraction scalars A genertor that given a trajectory will generate a scalar for each point such that each scalar represents the fraction of the total length along the path at the associated point.
- Parameters
trajectory (Trajectory) – The trajectory to use for generating scaler values
- Returns
Fraction length scalar values for each point in the trajectory
- tracktable.render.map_processing.common_processing.point_popup(current_point, point_popup_properties)[source]¶
Formats the popup string for a point
- Parameters
current_point (point) – Current point of the trajectory
point_popup_properties (list) – Point properties
- Returns
String of point properties
- tracktable.render.map_processing.common_processing.point_tooltip(current_point)[source]¶
Formats the tooltip string for a point
- Parameters
current_point (point) – Current point of the trajectory
- Returns
Current points timestamp
- tracktable.render.map_processing.common_processing.progress_linewidth_generator(trajectory)[source]¶
Generator to produce progress linewidth scalars A generator that given a trajectory will generate a scalar for each point such that each scalar represents a good width value for the fraction of points that come before that point in the trajectory.
- Parameters
trajectory (Trajectory) – The trajectory to use for generating scaler values
- Returns
Linewidth scalar values for each point in the trajectory
- tracktable.render.map_processing.common_processing.render_distance_geometry(backend, distance_geometry_depth, traj, map_canvas)[source]¶
Renders the distance geometry calculations to the folium map
- tracktable.render.map_processing.common_processing.render_line(backend, map_canvas, line_coords, control_color, weight, tooltip)[source]¶
Renders a line onto a cartopy or folium map
- Parameters
backend (str) – Backend to use rendering into. Only supports ‘cartopy’ and ‘folium’
map_canvas (GeoAxes) – The canvas where the line will be rendered
line_coords (tuple) – Lon lat coordinates where to render the line
control_color (float) – Color of the rendered line
weight (int) – Linewidth
tooltip (str) – Value to display for the line such as
object_id
- Returns
No return value
- tracktable.render.map_processing.common_processing.save_density_array(density, outfile)[source]¶
Save and output the density array to a file.
- tracktable.render.map_processing.common_processing.sub_trajs_from_frac(trajectories, zoom_frac)[source]¶
Create sub-trajectories from a given zoom fraction
- Parameters
trajectories (Trajectory) – Trajectories to create sub-trajectories from
zoom_frac (list) – Fraction list to segment trajectories
- Returns
sub_trajs