tracktable.rw.load module
Module contents
tracktable.rw.load: Load in trajectories or trajectory points from a file
This file will intelligently load in trajectory or trajectory point files for supported file types (.csv, .tsv, .traj). This includes automatic trajectory assembly if the file being loaded is a .csv or .tsv file as well as automatically utilizing the correct domain readers so points or trajectories are correctly associated with the Terrestrial or Cartesian domains.
- tracktable.rw.load.load_trajectories(infile, comment_character='#', domain='terrestrial', field_delimiter=',', object_id_column=0, timestamp_column=1, longitude_column=2, latitude_column=3, x_column=2, y_column=3, z_column=4, real_fields={}, string_fields={}, time_fields={}, separation_distance=None, separation_time=30, minimum_length=2, return_trajectory_points=False, return_list=True)[source]
Load trajectories or trajectory points from .csv, .tsv and .traj files
- Parameters:
infile (file-like object) – File path for trajectory data
- Keyword Arguments:
comment_character (character) – Any row where this is the first non-whitespace character will be ignored. (default: ‘#’)
delimiter (character) – What character separates columns? (default: ‘,’)
domain (str) – Which point domain will the points belong to? (default: ‘terrestrial’)
object_id_column (int) – Which column contains the object ID (default: 0)
timestamp_column (int) – Which column contains the timestamp (default: 1)
longitude_column (int) – Which column contains the longitude for each point? (default: 2, assumes terrestrial domain)
latitude_column (int) – Which column contains the latitude for each point? (default: 3, assumes terrestrial domain)
x_column (int) – Which column contains the X coordinate for each point? (default: 2, assumes cartesian2d or cartesian3d)
y_column (int) – Which column contains the Y coordinate for each point? (default: 3, assumes cartesian2d or cartesian3d)
z_column (int) – Which column contains the X coordinate for each point? (default: 4, assumes cartesian3d)
string_fields (dict, int -> string) – Columns in the input that should be attached to each point as a string. The keys in this dictionary are column numbers. Their corresponding values are the name of the field that will be added to the point’s properties. (default: empty)
real_fields (dict, int -> string) – Columns in the input that should be attached to each point as a real number. The keys in this dictionary are column numbers. Their corresponding values are the name of the field that will be added to the point’s properties. (default: empty)
time_fields (dict, int -> string) – Columns in the input that should be attached to each point as a timestamp. The keys in this dictionary are column numbers. Their corresponding values are the name of the field that will be added to the point’s properties. The timestamps must be in the same format as for the point as a whole, namely YYYY-mm-dd HH:MM:SS. (default: empty)
separation_distance (int) – Distance in KM between points signifying the need to generate a new trajectory. (default: 10)
separation_time (int) – Time in minutes between seperated points signifying the need to generate a new trajectory. (20)
return_trajectory_points (boolean) – When loading a .csv or .tsv file return the points in the file and don’t generate trajectories. When loading a .traj return a list of lists of the points that make up the given trajectory for all trajectories in the file. (default: False)
return_list (boolean) – When returning the reader or assembler object have the loader automatically pull all of the yielded trajectories into a list for further processing. (default: False)
- Returns:
List of trajectory points or trajectories depending on input file and params.
- Raises:
IOError – Unsupported filetype
ValueError – Unsupported domain or comment character