2

I started playing with the osmnx Python package and have to questions:

  1. Is the following minimal working example the correct way to plot additional geometries on top of my graph G or are there better ways?

  2. As you can see on the resulting plot below the code, the river (Tajo) is not completely colored. The blue stops abruptly, because the label must have changed. I tried out multiple tags, but could not find the appropriate one to color the rest of the river (you should see blue where the red circles are). Does anybody know what the correct tag is? (EDIT: It seems to be surrounded by a "costline" boundary)

import osmnx as ox

ox.config(log_console=False, use_cache=True)

# Coordinates Lisbon
bbox = [38.7969489, 38.6919296, -9.088, -9.2296891]

# Query graph for Lisbon
G = ox.graph_from_bbox(
    *bbox,
    simplify=True,
    retain_all=True,
    clean_periphery=True,
    truncate_by_edge=True,
    network_type="drive_service",
)

# Find additional geometries
water_1 = ox.geometries_from_bbox(*bbox, tags={"natural": ["water"]})
water_2 = ox.geometries_from_bbox(
    *bbox,
    tags={
        "waterway": ["riverbank", "canal", "dock"],
        "water": ["river", "canal", "reservoir"],
        "natural": ["bay"],
    },
)
water_3 = ox.geometries_from_bbox(*bbox, tags={"place": ["sea", "ocean"]})
motoway = ox.geometries_from_bbox(
    *bbox,
    tags={
        "highway": [
            "motorway",
            "motorway_link",
            "trunk",
            "trunk_link",
        ]
    },
)

# PLOT
fig, ax = ox.plot_graph(
    G,
    bgcolor="white",
    node_size=0,
    edge_linewidth=1,
    show=False,
    close=False,
    figsize=(60, 80),
    dpi=100,
    save=True,
    filepath="lisbon.jpg",
)

water_1.plot(color="#466A8C", linewidth=1, ax=ax)
water_2.plot(color="#466A8C", linewidth=1, ax=ax)
water_3.plot(color="#466A8C", linewidth=1, ax=ax)
motoway.plot(color="#000000", linewidth=2, ax=ax)

enter image description here

N8_Coder
  • 713
  • 3
  • 10
  • 20
  • 1
    For the first question yes, that seems good. For the second I am not sure I understand. Could you elaborate? – DPM Aug 20 '21 at 18:06
  • 1
    Have you plotted the boundaries separately? It might help to see if the geometries have the shape you expect – DPM Aug 22 '21 at 00:07
  • If I plot and color the boundaries (i.e. of the coastline), I can see that it correctly bounds the ocean area inside, but I am not able to color the ocean... – N8_Coder Aug 30 '21 at 08:25

0 Answers0