Answers.Body: <p>One approach you could consider is to use a geographic embedding algorithm that can handle &quot;random&quot; points on a street. GeoVec is one such example, but you may also want to consider other algorithms that have been specifically designed for embedding geographic data.</p>
  <p>One such algorithm is the Haversine distance, which is a measure of the great-circle distance between two points on a sphere. This algorithm is often used in geography to calculate the distance between two points on a globe, and can be easily applied to your problem by computing the Haversine distance between each pair of points in a given trajectory and using that as the basis for your embedding.</p>
  <p>Another approach you could consider is to use a graph-based algorithm for embedding your geographical data. In this approach, you would represent each point in your dataset as a node in a graph, and the distances between pairs of points as edges in the graph. You could then use a graph-based algorithm, such as DeepWalk or node2vec, to learn a low-dimensional representation of the nodes in the graph, which you could then use as the basis for your trajectory embedding.</p>
  <p>Regardless of which approach you choose, it's important to carefully evaluate the results of your embedding algorithm to ensure that it is able to capture the important characteristics of your data. This may require some experimentation and fine-tuning of the algorithm's parameters to achieve the best results.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-12-01T15:18:05.337Z
Answers.Text: Thank you for your detailed answer! A small question regarding graph-based embeddings: could one also consider a graph where the nodes are not single points but trajectories (polylines)? Because in that case, one could extract embeddings of each node (trajectory) using node2vec, as you pointed out. I think that code-wise it should be possible, however I am not sure if it would make sense (construction of a graph, how the edges are defined, distance between trajectories etc.)
Answers.UserDisplayName: I am not a robot
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-12-01T15:53:17.560Z
Answers.Text: Yes, it is possible to use graph-based embedding techniques like node2vec on a graph where the nodes are trajectories (polylines) rather than individual points.
Answers.UserDisplayName: Robin van Hoorn
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-12-01T14:51:30.053Z
Answers.LastActivityDate: 2022-12-01T14:51:30.053Z
Answers.UserDisplayName: Robin van Hoorn
Body: <p>I have a data that consists of approx. 1.5M taxi trips in Porto, Portugal. (from: <a href="https://www.kaggle.com/competitions/pkdd-15-taxi-trip-time-prediction-ii/overview" rel="nofollow noreferrer">https://www.kaggle.com/competitions/pkdd-15-taxi-trip-time-prediction-ii/overview</a>) Each of these trips have it's GPS trajectory traveled along as a feature, looking like [(41.146254, -8.613972), (41.146479, -8.614476)..., (41.163048, -8.583984)] (list of (lat, long) pairs). I would like to embed each of the points in a trajectory and the trajectory itself separately. My ultimate goal is to concatenate the embeddings with the embeddings of other features for each row in the dataset to a vector to perform clustering on it.</p>
  <p>I am looking for something like word2vec, glove, but for geographical domain. Until now, I have not found any benchmark method. I have found open source works like GeoVec (<a href="https://arxiv.org/pdf/2108.13092.pdf" rel="nofollow noreferrer">https://arxiv.org/pdf/2108.13092.pdf</a>), which shares vector embeddings for different OSM entities, however, I would probably have some points in my dataset which are not listed in the embeddings, as these are random points on a street a taxi traveled along and for which there is no OSM entity. Also, this approach would only solve the task of point embedding but not trajectory embedding. I am programming in python.</p>
  
Tags: <machine-learning><python><clustering><embeddings><representation-learning>
Title: How to get meaningful vector embeddings for (lat, long) points and also GPS trajectories?
UserDisplayName: I am not a robot
ThreadText: # How to get meaningful vector embeddings for (lat, long) points and also GPS trajectories?
  
  (Asked by: username_0 on 2022-12-01)
  
  I have a data that consists of approx. 1.5M taxi trips in Porto, Portugal. (from: <https://www.kaggle.com/competitions/pkdd-15-taxi-trip-time-prediction-ii/overview>) Each of these trips have it's GPS trajectory traveled along as a feature, looking like [(41.146254, -8.613972), (41.146479, -8.614476)..., (41.163048, -8.583984)] (list of (lat, long) pairs). I would like to embed each of the points in a trajectory and the trajectory itself separately. My ultimate goal is to concatenate the embeddings with the embeddings of other features for each row in the dataset to a vector to perform clustering on it.
  
  I am looking for something like word2vec, glove, but for geographical domain. Until now, I have not found any benchmark method. I have found open source works like GeoVec (<https://arxiv.org/pdf/2108.13092.pdf>), which shares vector embeddings for different OSM entities, however, I would probably have some points in my dataset which are not listed in the embeddings, as these are random points on a street a taxi traveled along and for which there is no OSM entity. Also, this approach would only solve the task of point embedding but not trajectory embedding. I am programming in python.
  
  **Tags:** machine-learning, python, clustering, embeddings, representation-learning
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-12-01. Score: 1 | Accepted answer
  
  One approach you could consider is to use a geographic embedding algorithm that can handle "random" points on a street. GeoVec is one such example, but you may also want to consider other algorithms that have been specifically designed for embedding geographic data.
  
  One such algorithm is the Haversine distance, which is a measure of the great-circle distance between two points on a sphere. This algorithm is often used in geography to calculate the distance between two points on a globe, and can be easily applied to your problem by computing the Haversine distance between each pair of points in a given trajectory and using that as the basis for your embedding.
  
  Another approach you could consider is to use a graph-based algorithm for embedding your geographical data. In this approach, you would represent each point in your dataset as a node in a graph, and the distances between pairs of points as edges in the graph. You could then use a graph-based algorithm, such as DeepWalk or node2vec, to learn a low-dimensional representation of the nodes in the graph, which you could then use as the basis for your trajectory embedding.
  
  Regardless of which approach you choose, it's important to carefully evaluate the results of your embedding algorithm to ensure that it is able to capture the important characteristics of your data. This may require some experimentation and fine-tuning of the algorithm's parameters to achieve the best results.
  
  > **Comments:**
  > **username_0**: Thank you for your detailed answer! A small question regarding graph-based embeddings: could one also consider a graph where the nodes are not single points but trajectories (polylines)? Because in that case, one could extract embeddings of each node (trajectory) using node2vec, as you pointed out. I think that code-wise it should be possible, however I am not sure if it would make sense (construction of a graph, how the edges are defined, distance between trajectories etc.)  
  > **username_1**: Yes, it is possible to use graph-based embedding techniques like node2vec on a graph where the nodes are trajectories (polylines) rather than individual points.  
  
  ---
  
  