Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new from_osmnx_graph constructor #206

Open
nreinicke opened this issue Mar 17, 2025 · 0 comments
Open

Add new from_osmnx_graph constructor #206

nreinicke opened this issue Mar 17, 2025 · 0 comments

Comments

@nreinicke
Copy link
Collaborator

In order to simplify the creation of an NxMap from an osmnx graph, we could create a new classmethod, something like NxMap.from_osmnx_graph that returns an NxMap from an osmnx graph. Most of the plumbing is already in place but it would just clean up how the user builds the map. Currently, the procedure for getting an NxMap from an arbitrary osmnx graph looks like this:

import osmnx as ox
from mappymatch.maps.nx.readers.osm_readers import parse_osmnx_graph, NetworkType

# define a bounding box (left, bottom, right, top)
bbox = -122.43, 37.78, -122.41, 37.79

# create network from that bounding box
G = ox.graph.graph_from_bbox(bbox, network_type="drive")

nxmap = NxMap(parse_osmnx_graph(G, network_type=NetworkType.DRIVE))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant