Search code examples
openstreetmaposmnx

Plotting/importing rivers in OSMnx


I found someone asked a question for how to plot/import the objects other than roads, but he/she didn't get the answer.

Here is the link: Plotting different area objects in OSMnx

I was able to download/install OSMnx and run the examples of OSMnx at "https://github.com/gboeing/osmnx-examples.git".

My interest is on water (i.e., river, reservoir, lake, etc.).

How can I import and plot river/reservoir/lake of Open Street Map from Python?


Solution

  • Per this answer, to model and plot waterways:

    import osmnx as ox
    ox.config(use_cache=True, log_console=True)
    G = ox.graph_from_place('Amsterdam', retain_all=False, truncate_by_edge=False,
                            simplify=True, custom_filter='["waterway"~"canal"]')
    fig, ax = ox.plot_graph(G)
    
    

    More details available in this example.