Comments (3)
Try changing the parameters of graph.graph_from_bbox and candidate.get_candidates as follows:
import pandas as pd
import numpy as np
from pytrack.graph import graph, distance
from pytrack.analytics import visualization
from pytrack.matching import candidate, mpmatching_utils, mpmatching
import matplotlib.pyplot as plt
df = pd.read_csv("reproduce.csv")
# Extract latitude and longitude directly as a list of tuples
points = [(lat, lon) for lat, lon in zip(df["latitude"], df["longitude"])]
# Calculate the bounding box using Numpy functions
north, east = np.max(points, axis=0)
south, west = np.min(points, axis=0)
# Extract road network graph
G = graph.graph_from_bbox(*distance.enlarge_bbox(north, south, west, east, 500), simplify=True, network_type='drive')
# Visualize the extracted graph on a map centered around the mean location
maps = visualization.Map(location=(np.mean(df["latitude"]), np.mean(df["longitude"])))
maps.add_graph(G, plot_nodes=False)
# Extract and plot candidates
G_interp, candidates = candidate.get_candidates(G, points, interp_dist=20, closest=True, radius=30)
maps.draw_candidates(candidates, 30)
# Extract trellis DAG graph
trellis = mpmatching_utils.create_trellis(candidates)
trellis_draw = visualization.draw_trellis(trellis, figsize=(15, 100), dpi=100)
plt.show()
# Perform the map-matching process
path_prob, predecessor = mpmatching.viterbi_search(G_interp, trellis, "start", "target", beta=3, sigma=5))
# Plot map-matching results
maps.draw_path(G_interp, trellis, predecessor)
maps.save("reproduce.html")
In this way, I obtain the following results:
If it is no problem, remember to leave a star for the repository.
from pytrack.
This is strange behaviour. I think it is because the points are very spread out. Is it possible to get the simulation data to reproduce the error?
See you soon
from pytrack.
Hello,
I apologize for the delay in responding; I have been quite busy and, unfortunately, overlooked the GitHub issues. Attached, please find the files necessary for reproduction.
Thank you for your patience.
code snippet:
import pandas as pd
import numpy as np
from pytrack.graph import graph, distance
from pytrack.analytics import visualization
from pytrack.matching import candidate, mpmatching_utils, mpmatching
import matplotlib.pyplot as plt
df = pd.read_csv("reproduce.csv")
# Extract latitude and longitude directly as a list of tuples
points = [(lat, lon) for lat, lon in zip(df["latitude"], df["longitude"])]
# Calculate the bounding box using numpy functions
north, east = np.max(points, axis=0)
south, west = np.min(points, axis=0)
# Extract road network graph
G = graph.graph_from_bbox(*distance.enlarge_bbox(north, south, west, east, 500), simplify=False, network_type='drive')
# Visualize the extracted graph on a map centered around the mean location
maps = visualization.Map(location=(np.mean(df["latitude"]), np.mean(df["longitude"])))
maps.add_graph(G, plot_nodes=False)
# Extract and plot candidates
G_interp, candidates = candidate.get_candidates(G, points, interp_dist=5, closest=True, radius=30)
maps.draw_candidates(candidates, 30)
# Extract trellis DAG graph
trellis = mpmatching_utils.create_trellis(candidates)
trellis_draw = visualization.draw_trellis(trellis, figsize=(15, 100), dpi=100)
plt.show()
# Perform the map-matching process
path_prob, predecessor = mpmatching.viterbi_search(G_interp, trellis, "start", "target")
# Plot map-matching results
maps.draw_path(G_interp, trellis, predecessor)
maps.save("reproduce.html")
from pytrack.
Related Issues (8)
- BUG: using GPS trajectory to find path with OSM results in multiple exceptions HOT 2
- Performance problem with pytrack, not sure what is the root cause HOT 1
- BUG: Crash when path ends in a driveway not reachable from the beginning HOT 1
- Installation error: Minimum supported PROJ version is 8.0.0, installed version is 5.2.0.
- Problem in the draw path HOT 4
- KeyError: 'geometry' HOT 8
- get matched points HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytrack.