Comments (1)
Hi,
the problem is due to the fact that there are two isolated graphs, where in the second smaller one a candidate point of the last gps coordinate (61.46429, 23.7183) lies.
The problem, as you say, is due to the point being in a parking area and network_type='drive' does not take into account parking lots when constructing the road graph.
However, from PyTrack version 2.0.8 (you have 2.0.6) it is possible to define custom network_type.
Below is the working code and the results obtained.
Remember to leave a star for the repository 🤟
import numpy as np
from pytrack.graph import graph, distance
from pytrack.matching import candidate, mpmatching_utils, mpmatching
from pytrack.analytics import visualization
coords = [
(61.464851, 23.72293),
(61.464935, 23.721074),
(61.465018, 23.719238),
(61.464761, 23.718313),
(61.46429, 23.7183)]
north, east = np.max(np.array([*coords]), 0)
south, west = np.min(np.array([*coords]), 0)
custom_filter = ('["highway"]["area"!~"yes"]["access"!~"private"]'
'["highway"!~"abandoned|bridleway|bus_guideway|construction|corridor|cycleway|'
'elevator|escalator|footway|path|pedestrian|planned|platform|proposed|raceway|steps|track"]'
'["service"!~"emergency_access|private"]')
G = graph.graph_from_bbox(*distance.enlarge_bbox(north, south, west, east, 500), simplify=True, custom_filter=custom_filter)
G_interp, candidates = candidate.get_candidates(G, coords, interp_dist=10, closest=True, radius=30)
trellis = mpmatching_utils.create_trellis(candidates)
path_prob, predecessor = mpmatching.viterbi_search(G_interp, trellis, "start", "target")
loc = (np.mean(np.array([*coords])[:, 0]), np.mean(np.array([*coords])[:, 1]))
maps = visualization.Map(location=loc, zoom_start=15)
maps.draw_candidates(candidates, 30)
maps.add_graph(G, plot_nodes=True)
maps.draw_path(G_interp, trellis, predecessor)
maps
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
- Issues with draw_path function: Lines not aligned with roads HOT 3
- 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.