TPTK is a trajectory preprocessing toolkit in Python.
Note that, this is only my personal implementation. For the industrial level quality and efficiency, you're welcome to try our product JUST.
Currently, TPTK serves as a basic library of DeepMG.
-
Data Structures
- SPoint
- The fundamental spatial point class
- MBR
- Minimum bounding box
- Trajectory
- A sequence of time-ordered spatio-temporal points
- Directed & Undirected Road Network
- A custom class with routing and spatial query support
- I/O with OpenStreetMap data (Please refer to osm2rn)
- SPoint
-
Basic Spatial Functions
- Distance Calculation
- Haversine distance
- Spatial Griding
- Split a given mbr into specified size/interval grid cells
- Line Segment Simplification
- Douglas-Peucker algorithm
- Distance Calculation
-
Data Manipulation
- Spatial Query (TODO: indexing)
- Spatio-temporal Query (TODO: indexing)
-
Trajectory Preprocessing Algorithms
-
Noise Filtering
- Spatio-temporal Range Filter
- Heuristic Filter
-
Segmentation
- Time Interval-based Segmentation
- Stay Point-based Segmentation
-
Stay Point Detection
- Classical Stay Point Detection
- Density-based Stay Point Detection
-
Map Matching
- Algorithms
- Hidden Markov Map Matching
- Output Formats
- Matched GPS point list
match
- Matched path
match_to_path
- Matched GPS point list
- Algorithms
-
-
Trajectory Statistics
- Summary: #objects, #points, #trajectories
- Distribution: #points, time interval, distance interval, length, duration
-
Trajectory Data
- There are some open-source trajectory datasets, e.g., TDrive.
-
Road Network Data
- OpenStreetMap (OSM) is an open-source map data source
- The Shapefile Road Network Format can be generated by osm2rn.
- Clean Trajectories
python main.py --phase clean --tdrive_root_dir ./data/taxi_log_2008_by_id/ --clean_traj_dir ./data/tdrive_clean/
- Map-match Trajectories
python main.py --phase mm --clean_traj_dir ./data/tdrive_clean/ --rn_path ./data/Beijing-16X16-latest/ --mm_traj_dir ./data/tdrive_mm/
- Trajectory Statistics
python main.py --phase stat --clean_traj_dir ./data/tdrive_clean/
If you find our code useful for your research, please cite our papers:
Sijie Ruan, Ruiyuan Li, Jie Bao, Tianfu He, Yu Zheng. "CloudTP: A Cloud-based Flexible Trajectory Preprocessing Framework". ICDE 2018.
Sijie Ruan, Cheng Long, Jie Bao, Chunyang Li, Zisheng Yu, Ruiyuan Li, Yuxuan Liang, Tianfu He, Yu Zheng. "Learning to Generate Maps from Trajectories". AAAI 2020.
TPTK uses the following dependencies with Python 3.6
- rtree==0.8.3
- networkx==2.3
- GDAL==2.3.2
Other packages can be easily installed using conda install
, while the following scripts are recommended for gdal
.
conda install -c conda-forge gdal==2.3.2