Skip to content

Add new from_osmnx_graph constructor #206

@nreinicke

Description

@nreinicke

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions