Abstract
Spatiotemporal data faces many analogous challenges to natural language text including the ordering of locations (words) in a sequence, long range dependencies between locations, and locations having multiple meanings. In this work, we propose a novel model for representing high dimensional spatiotemporal trajectories as sequences of discrete locations and encoding them with a Transformer-based neural network architecture. Similar to language models, our Sequence Transformer for Agent Representation Encodings (STARE) model can learn representations and structure in trajectory data through both supervisory tasks (e.g., classification), and self-supervisory tasks (e.g., masked modelling). We present experimental results on various synthetic and real trajectory datasets and show that our proposed model can learn meaningful encodings that are useful for many downstream tasks including discriminating between labels and indicating similarity between locations. Using these encodings, we also learn relationships between agents and locations present in spatiotemporal data.
Introduction
Spatiotemporal data—the "where" and "when" of moving objects—is notoriously difficult to model due to its high dimensionality, continuous nature, and irregular sampling. Traditional approaches frequently rely on "side information" like road networks or points-of-interest (POI) databases to make sense of the noise. However, road networks change, and POI data isn't always available, especially in wildlife tracking or remote areas.
This research identifies a fundamental analogy: movement is like language. Just as words change meaning based on the words around them, a location's "meaning" changes based on the sequence of a journey. To capture this "grammar of movement," the authors propose the Sequence Transformer for Agent Representation Encodings (STARE) model, which learns directly from raw GPS pings without requiring external map data.
Methodology
The STARE model treats spatiotemporal trajectories as sequences of discrete tokens, leveraging the Transformer architecture—the same engine behind Large Language Models (LLMs)—to encode mobility patterns.
Data Discretization and Tokenization
To turn continuous GPS points into discrete "words," the model maps latitude and longitude to S2 cells (a hierarchical spatial index). It also discretizes the time spent at each "Persistent Location" (PL) into fixed increments. A trajectory is then converted into a structured sequence of tokens: a start token, a sequence of visited locations, a separator, a sequence of durations, and an end token.
Model Architecture
The core of STARE is a Transformer Encoder Stack (TES). Because the model processes the entire sequence at once via self-attention, it can capture long-range dependencies that traditional Recurrent Neural Networks (RNNs) might miss.
The model is trained using two primary tasks:
- Classification: Predicting the ID or subpopulation of an agent.
- Masked Location Modeling (MLM): Similar to how BERT is trained, the model hides certain locations in a sequence and tries to predict them. This self-supervised task forces the model to learn the "structure" of the environment and the functional layout of a city purely from movement data.
Experimental Results
STARE was evaluated on simulated "Patterns of Life" datasets (ranging from 37 to 11,000 agents), a massive 15-month simulation of three metropolitan areas, and real-world wildlife data from ravens in the Alps.
Performance and Semantic Embeddings
On the massive Atlanta dataset, STARE achieved 88.1% accuracy in identifying agents, significantly outperforming standard LSTM (66.4%) and BiLSTM (73.5%) models. Beyond raw accuracy, the model learns semantic embeddings where locations that are geographically proximal or functionally similar end up with similar vector representations.
Subpopulation Discovery
The model excels at discovering social subpopulations. When the model misclassifies an agent, it rarely makes a random guess; instead, it confuses agents who share similar "Patterns of Life" (e.g., living in the same suburb and working in the same office park). In the raven dataset, STARE successfully clustered the birds into four distinct spatial groups, proving the model can extract meaningful patterns even from noisy, real-world biological data.
Conclusion
STARE demonstrates that Transformer-based architectures can effectively encode the complex "grammar" of movement. By learning implicit maps and social structures from raw trajectories, it offers a powerful tool for spatiotemporal analysis. Future work will focus on scaling to millions of agents and further integrating multi-task learning to create even more robust representations.
Summary updated