0

I'm looking to construct a network of both streets and rivers using OSMnx

I was trying this:

country_graph = ox.graph_from_polygon(polygon=drc_boundary.geometry.iloc[0], simplify=True, retain_all=True, custom_filter='["waterway"~"river"]["highway"~"primary|trunk"]')

But this would give an error:

EmptyOverpassResponse: There are no data elements in the response JSON

Is there a way to do so using the custom filter, or should I get the street network and water network separately and then combine them together?

Mustafa Özçetin
  • 1,893
  • 1
  • 14
  • 16

1 Answers1

1

You are querying for ways that match both conditions: waterway=True and highway=primary|trunk. No ways match both those conditions. You instead need to get the waterways first, then the highways second:

import networkx as nx
import osmnx as ox
point = -3.399514, 17.402937
G1 = ox.graph_from_point(point, dist=20000, retain_all=True, truncate_by_edge=True,
                         custom_filter='["waterway"~"river"]')
G2 = ox.graph_from_point(point, dist=20000, retain_all=True, truncate_by_edge=True,
                         custom_filter='["highway"~"primary|trunk"]')
G = nx.compose(G1, G2)
print(len(G1), len(G2), len(G))  # 12 6 18

See also:

gboeing
  • 5,691
  • 2
  • 15
  • 41