Search code examples
networkxopenstreetmaposmnx

OSMNx: How to return OSM roads using graph_from_point even if its extreme end nodes are not within the distance


I want to fetch the road network inside the blue circle. But i am not able to do so as its far end nodes are well beyond 100 meter from the point. enter image description here

lng,lat=8.89458178871303, 41.657804855447374

road_filter =  '["highway"~"secondary"]'
G=ox.graph_from_point((lat, lng),custom_filter=road_filter,dist=100)

Solution

  • G=ox.graph_from_point((lat, lng),custom_filter=road_filter,dist=100,simplify=False,retain_all=True,truncate_by_edge=True)
    

    simplify=False and truncate_by_edge=True did the trick. enter image description here