In my project “Trajectory Analytics Toolbox”, I will be creating a general-purpose trajectory analytics toolbox in R. See my first blog post for more background information.
At the moment, the package is split up into the following functionalities:
- Classes for storing sf trajectories called sfTrack and sfTracks
- Methods for sfTrack and sfTracks (including plotting, transformations, coercion to data frame, intersections, and more)
- General trajectory analysis and visualization methods in traviz-methods
sfTrack and sfTracks class
To begin, I have created classes for storing sf trajectories and have called them sfTrack and sfTracks. sfTrack stores a single sf trajectory with slots for time, data, point geometry, and line geometry. sfTracks stores multiple sfTrack objects into a list. I have followed a similar model to the trajectories package while creating these classes. To create an sfTrack object, I have created a method called geodata_to_sf in traviz-methods that takes trajectory data and converts it to sf format. The data is then ported to sfTrack. I also have created a trajectory dataframe to sfTracks convertor, which creates an sfTracks object out of a data frame of trajectories. Once the data is in sfTrack or sfTracks format, it is possible to further visualize and analyze them. I have created functionality for plotting with ggplot2, intersection visualization, clustering, space time cube visualization inheriting the method from trajectories, and sf functions. The sfTrack and sfTracks classes also contain basic print functions to return general information about the trajectory such as the geographic bounding box and time interval during which the track took place. Finally, I have also included a coercion method to the Tracks data structure in order to also gain access to some methods present in trajectories.
The rest of the package functionality is in the traviz-methods, which I have not yet ported to sfTrack and sfTracks. I will do this in the upcoming weeks. I have added functionality for heat map visualization, raster POI/ROI analysis and visualization, aggregation and subsetting of trajectories, animation of trajectories, and point pattern analysis. The following is a detailed list of the features:
- Raster: rasterize based off value (e.g. CO2 value, speed value, etc.), use inverse distance weighted interpolation, aggregation to region of interest, resolution of interest, and time period of interest
- Heat map: Kernel density heat map of trajectory measurements at desired resolution, intersection density heat map, quadrat intensity heat map
- Advanced visualization tools: space time cube support for individual trajectories and animation support for individual trajectories
With these methods, it is possible to gain further insight into trajectory data and meaningfully visualize this data too.
In the upcoming weeks, I will be porting all of the traviz-methods to sfTrack and sfTracks. I will also be adding additional support for point pattern analysis. One of the methods that I will be using is the Getis-Ord Gi* statistic in order to get detailed statistical knowledge on hotspots in a geographic region. Finally, I will be adding individual segment analysis tools and detailed visualization of road segments by time, location, and selected measurement.