OSMnx is an incredible Python library that allows us to analyze and visualize urban networks using OpenStreetMap data. In this case, we will use OSMnx to explore the pedestrian, road, and bike networks in the beautiful city of Nantes.
Here is the code we will use to obtain and visualize these networks:
import osmnx as ox
import matplotlib.pyplot as plt
# Get the city of Nantes and its pedestrian network
place_name = "Nantes, France"
graph = ox.graph_from_place(place_name, network_type='walk')
# Create a figure and axis for the pedestrian network
fig, ax = ox.plot_graph(graph, figsize=(10, 10), node_color='b', node_size=30, edge_color='gray')
ax.set_title('Pedestrian Network of Nantes')
# Show the figure
plt.show()
# Get the road network of Nantes for cars
graph = ox.graph_from_place(place_name, network_type='drive')
# Create a figure and axis for the road network
fig, ax = ox.plot_graph(graph, figsize=(10, 10), node_color='b', node_size=30, edge_color='gray')
ax.set_title('Road Network of Nantes for Cars')
# Show the figure
plt.show()
# Get the bike network of Nantes
graph = ox.graph_from_place(place_name, network_type='bike')
# Create a figure and axis for the bike network
fig, ax = ox.plot_graph(graph, figsize=(10, 10), node_color='b', node_size=30, edge_color='gray')
ax.set_title('Bike Network of Nantes')
# Show the figure
plt.show()
This code uses OSMnx to obtain the pedestrian, road, and bike networks of Nantes. Each network is then displayed separately using ox.plot_graph
, allowing us to appreciate the connectivity and available routes for each mode of transportation.
We hope this visualization inspires you to explore the various urban networks in Nantes and promote sustainable and environmentally friendly modes of transportation! ππ±
You can use this post as a base and add any additional details or supplementary information you wish to highlight. Enjoy exploring the urban networks of Nantes with OSMnx and Python!