GithubHelp home page GithubHelp logo

Comments (3)

mtortora-ai avatar mtortora-ai commented on June 1, 2024 1

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:
github_issue

If it is no problem, remember to leave a star for the repository.

from pytrack.

mtortora-ai avatar mtortora-ai commented on June 1, 2024

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.

bodong66 avatar bodong66 commented on June 1, 2024

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")

reproduce.csv

from pytrack.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.