RNTrajRec: Road Network Enhanced Trajectory Recovery with Spatial-Temporal Transformer

Yuqi Chen, Hanyuan Zhang, Weiwei Sun, Baihua Zheng

Abstract

GPS trajectories are the essential foundations for many trajectory-based applications, such as travel time estimation, traffic prediction, and trajectory similarity measurement. Most applications require a large amount of high sample rate trajectories to achieve good performance. However, many real-life trajectories are collected with low sample rates due to energy concerns or other constraints. We study the task of trajectory recovery in this paper as a means for increasing the sample rate of low sample trajectories. Currently, most existing works on trajectory recovery follow a sequence-to-sequence diagram, with an encoder to encode a trajectory and a decoder to recover real GPS points. However, these works ignore the topology of the road network and only use grid information or raw GPS points as input. Therefore, the encoder model is not able to capture rich spatial information, making the prediction less accurate and lacking spatial consistency. In this paper, we propose a road network enhanced transformer-based framework, namely RNTrajRec, for trajectory recovery. RNTrajRec first uses a graph model, GridGNN, to learn the embedding features of each road segment. It next develops a spatial-temporal transformer model, GPSFormer, to learn rich spatial and temporal features along with a Sub-Graph Generation module. It finally forwards the outputs into a multi-task decoder model to recover the missing GPS points. Extensive experiments based on three large-scale real-life trajectory datasets confirm the effectiveness of our approach.

Introduction

In the real world, GPS trajectories are often collected at low sampling rates (e.g., one point every 2–6 minutes) to save battery life on mobile devices or reduce data transmission costs. However, applications like traffic prediction and travel time estimation require high-frequency data to be effective. Existing trajectory recovery methods typically struggle with two main issues: ignoring road topology, which leads to spatially inconsistent predictions, and using weak encoders like basic RNNs that fail to capture long-range contextual information in complex urban environments.

Methodology

The RNTrajRec framework addresses these challenges by breaking the recovery process into three main components:

  1. GridGNN (Road Network Representation): To understand the city layout, the model partitions the map into a grid. Each road segment is treated as a sequence of these grids. A Gated Recurrent Unit (GRU) learns the sequence of grids for each road, and a Graph Attention Network (GAT) captures how these roads connect to one another.
  2. GPSFormer (The Encoder): This is the core innovation. Instead of treating a GPS point as a simple coordinate, the model uses a Sub-Graph Generation module to represent each point as a weighted sub-graph of nearby road segments. The GPSFormer then uses a Graph Refinement Layer (GRL) to fuse temporal features with spatial features using gated fusion and "Graph Norm."
  3. Multi-task Decoder: The encoder's output is fed into a decoder that simultaneously predicts two things for every missing timestamp: the Road Segment ID and the Moving Ratio (the specific position along that road segment).
The overall architecture of RNTrajRec, illustrating the integration of GridGNN, GPSFormer, and the multi-task decoder.

Key Insights and Innovations

GPS Points as Sub-graphs

By representing a noisy or sparse GPS coordinate as a sub-graph of nearby roads, the model inherently accounts for measurement errors and "snaps" the trajectory to the most likely physical path. This ensures that the recovered points are not just mathematically interpolated but are physically grounded in the road network.

Visual representation of mapping sparse GPS points (q) to road network sub-graphs to maintain spatial consistency during recovery.

Spatial-Temporal Fusion

Standard Transformers use multi-head attention for sequence modeling. RNTrajRec enhances this by using a Gated Fusion mechanism to combine temporal sequence data (the vehicle's history) with spatial graph data (the local road structure). This is particularly effective for solving the "Elevated Road" problem, where the model must distinguish between a highway and a local street running directly beneath it based on network connectivity.

Experimental Results

The model was evaluated on three large-scale, real-world trajectory datasets: Shanghai-L, Chengdu, and Porto. High-frequency data (10–15s intervals) served as the ground truth, downsampled by factors of 8x and 16x to simulate low-sample input.

  • Superior Accuracy: RNTrajRec outperformed all baselines, including MTrajRec and GTS. In the Chengdu dataset, it improved the F1 score by approximately 4.85% and reduced the Mean Absolute Error (MAE) by 27.42 meters compared to the best baseline.
  • Robustness: In complex road scenarios, RNTrajRec achieved an F1 score of >0.8 for nearly 60% of trajectories, significantly higher than traditional Hidden Markov Models (HMM).
  • Efficiency: The model is highly efficient, requiring only ~50ms to recover a trajectory during inference, making it viable for real-time applications.

Conclusion

RNTrajRec demonstrates that explicitly integrating road network topology into a transformer-based architecture significantly improves the accuracy and spatial consistency of trajectory recovery. While the model shows some dependency on large training volumes and grid-size sensitivity, its ability to handle complex urban layouts makes it a powerful tool for modern traffic management and analysis.

Summary updated

Abstract

GPS trajectories are the essential foundations for many trajectory-based applications, such as travel time estimation, traffic prediction and trajectory similarity measurement. Most applications require a large amount of high sample rate trajectories to achieve a good performance. However, many real-life trajectories are collected with low sample rate due to energy concern or other constraints.We study the task of trajectory recovery in this paper as a means for increasing the sample rate of low sample trajectories. Currently, most existing works on trajectory recovery follow a sequence-to-sequence diagram, with an encoder to encode a trajectory and a decoder to recover real GPS points in the trajectory. However, these works ignore the topology of road network and only use grid information or raw GPS points as input. Therefore, the encoder model is not able to capture rich spatial information of the GPS points along the trajectory, making the prediction less accurate and lack spatial consistency. In this paper, we propose a road network enhanced transformer-based framework, namely RNTrajRec, for trajectory recovery. RNTrajRec first uses a graph model, namely GridGNN, to learn the embedding features of each road segment. It next develops a spatial-temporal transformer model, namely GPSFormer, to learn rich spatial and temporal features along with a Sub-Graph Generation module to capture the spatial features for each GPS point in the trajectory. It finally forwards the outputs of encoder model into a multi-task decoder model to recover the missing GPS points. Extensive experiments based on three large-scale real-life trajectory datasets confirm the effectiveness of our approach.
BibTeX
@inproceedings{chen2023rntrajrec,
  author = {Yuqi Chen and Hanyuan Zhang and Weiwei Sun and Baihua Zheng},
  title = {{RNTrajRec: Road Network Enhanced Trajectory Recovery with Spatial-Temporal Transformer}},
  booktitle = {ICDE},
  year = {2023},
  doi = {10.1109/icde55515.2023.00069},
}
Figure