GSoC2020 Project: Trajectory Analytics Toolbox


Student: John Murzaku

Mentor: Dr. Benedikt Graeler (b.graeler@52north.org)

Introduction

I will be creating a general purpose trajectory analytics toolbox in R called traviz. This project will be using the existing R package trajectories and will be adding sf and sftime support. It will add the features mentioned above and use the Track data structure. To demonstrate functionality of the toolbox and perform tests on the package, enviroCar data will be used. In order to collect enviroCar data, the envirocar-py package will be used. The main functionality of the toolbox will include the following:
  • Analysis of trajectory data
  • Visualization of trajectory data (i.e. space-time cubes, animations, heat maps, hot-spot clusters)
  • Aggregation and subsetting of trajectory data

Weekly Report

Week 1: June 1st to June 8th

Status:
  • Collected enviroCar data using envirocar-py to use for testing and function implementation
  • Converted enviroCar data to sf and then to LINESTRING. Visualized the trajectories in Munster using ggplot2
  • Created a data pipeline that takes enviroCar data, converts it to sf format, and then fits it into the Track data structure
  • Began work on sf functionality in Track data structure by allowing Track to accept sf formatted data
  • Started working on raster data pipeline. Implemented raster aggregation to a region of interest, time of interest, desired resolution, and values of interests
  • Created raster visualizations of speeds of vehicles at Munster, Germany during rush hour (16:00 - 18:00) on a user selected day
  • Learned about CRS and how raster works in R
  • Began implementation of generalized raster aggregation functions
Problems:
  • How do I deal with NA values in raster data? This is affecting the visualizations a little bit because it has blank spots where a car does not have a recorded speed for example
  • How do I deal with CRS in the raster data? At the moment I am changing the CRS manually but this seems to be inefficient
  • Need to fully understand the Track data structure more in order to effectively add sf support
Next week tasks:
  • Finish implementation of generalized raster aggregation functions. Write documentation, tests, and demos
  • Create raster visualization functions to users desired aggregation and resolution. Write documentation, tests, and demos
Daily log:

Week 2: June 8th to June 15th

Status:
  • Created Github repository of traviz (https://github.com/JamMurz/traviz)
  • Created and implemented generalized functions for conversion to sf, LINESTRING, raster, and stars formats
  • Created and implemented sf to Track function
  • Added functionality for sf and raster aggregation to region of interest and time of interest
  • Created function for inverse distance weighted interpolation of raster data
  • Created preliminary function for clustering trajectories
  • Created preliminary function for finding trajectory intersection density
  • Began experimenting with animating trajectory data from point to point using gganiminate
  • Began experimenting with kernel density estimates for trajectories to find intersection hot spots
Problems:
  • Some of the functions appear to be too specific for enviroCar data. I will need to generalize them more to fit most trajectory data. I am thinking of requiring the package to only accept sf and sftime data
  • gganimate takes a long time to animate point to point time measurements of individual trajectories. I need to limit trajectory animations to one at a time or find another package
Next week tasks:
  • Finalize current functions and make them more general purpose
  • Start working on trajectory hot spot analysis tools
Daily log: Week 3: June 15th to June 22nd

Status:
  • Added the following functions to traviz:
    • Trajectory clustering by Frechet distance
    • Trajectory heatmap that returns kernel density heatmap
    • Trajectory value heatmap to find density of values (i.e. where speeds are higher or CO2 values are higher in a city)

  • Began implementation of trajectory animation function
  • Began implementation of using kernel density estimation and quadrat for heatmap
  • Created a generic class sfTrack and sfTracks to store sf trajectories
  • Added the following generic methods to sfTrack:
    • Plotting individual or multiple trajectories with ggplot2
    • Finding distance between two tracks
    • Coercing sfTrack to trajectories::Track
    • Transforming projection of sfTrack
    • Printing sfTrack

Problems:
  • Animations still take too long(even for individual short trajectories) and requires a lot of computational power. This could not scale well for every user. I am using moveVis for this
  • The sfTrack class does not yet take connections into account like trajectories does
Next week tasks:
  • Finalize generic methods for sfTrack and sfTracks
  • Convert all current methods in traviz-methods to work with sfTrack and sfTracks
  • Update Shiny app periodically as new methods to traviz are added
Daily log: Week 4: June 22nd to June 29th

Status:
  • Added functionality for generic sf/sp/trajectories methods to the sfTrack and sfTracks classes. These include
    • st_bbox
    • st_length
    • st_intersections with ggplot2 visualization and optional zoom parameter
    • stcube from trajectories
  • Added coercion from sfTracks to data.frame
  • Began rewriting of geodata_to_sf for general use cases
  • traviz is now able to be installed and all CRAN checks pass. If interested in testing, you can use the following command to install it:
    • devtools::install_github("JamMurz/traviz")
  • Added roxygen documentation to all methods
  • Created a Shiny application of traviz with the following methods:
    • Interactive trajectory plotting (from a subset of enviroCar trajectories in Munster, Germany)
    • Interactive trajectory intersection plotting
    • Rasterization of data with value and resolution of choice. Functionality for subsetting based off latitude and longitude included also
    • Heatmap of value with resolution and value parameters included
    • Quadrat plot of trajectories
    • Frechet distance clusters of trajectories
Problems:
  • The traviz-methods are still not ported to sfTrack and sfTracks
  • There are errors when subsetting the rasterized values off time. I will need to add fixes to the sf_to_rasterize function
Next week tasks:
  • Port all traviz-methods to sfTrack and sfTracks
  • Add methods for hotspot analysis using Getis-Ord
  • Fix the time errors in the sf_to_rasterize function
Daily log: Link to Shiny application: https://jammurz.shinyapps.io/traviz-shiny/?_ga=2.238498951.665889296.1593375892-939092745.1593375892

Week 5: June 29th to July 6th

Status:
  • Added Getis-Ord visualization method to traviz-methods
  • Added sfTrack and sfTracks support to traviz-methods through coercion to data frame and accepting sfTrack as a parameter
  • Added aggregation by time to sfTrack
  • Added functionality for making a 24 hour heatmap plot in density_heatmap function
  • Began creation of individual segment analysis tools
  • Added aggregation by weekday
  • A lot of time was spent debugging this week and fixing current functions for more general support or to fix potential problems. The following was fixed:
    • Bugs in Shiny application due to traviz updates
    • geodata_to_sf convertor
    • To and from time aggregation in sf_to_rasterize. This was fixed by using the tibbletime library for easier time manipulation
    • The constructor for sfTrack created errors when coercing from data frame to sfTrack. This was fixed
    • sf_intersection inheritance was fixed
Problems:
  • The 24 hour heatmap plot returns errors when there are NA's in the data. A fix for this could be removing all NA's but that will not tell the whole story of the data
Next week tasks:
  • Finish individual segment analysis tools
    • The segment analysis tools will aggregate all trajectory data on a given weekday and return visualization and analysis of this data
  • Add better visualization to Getis-Ord method
Daily Log:
Topic revision: r7 - 06 Jul 2020, JohnMurzaku
Legal Notice | Privacy Statement


This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Wiki? Send feedback