1

I'm trying to get different classifications of road type in OSM with python, after browsed several relevant web pages, I've got this so far:

import osmnx as ox
place_name = "zurich, switzerland"
graph = ox.graph_from_place(place_name, network_type='drive')
fig, ax = ox.plot_graph(graph, fig_height=5, node_size=0)

the network_type only include 'drive','walk',etc but I'd like to get the Highway tag, like'primary','secondary','tertiary',this kind of type road network respectively, how should I do?

scai
  • 20,297
  • 4
  • 56
  • 72
Lan Ma
  • 11
  • 2

1 Answers1

0

I'd like to get the Highway tag, like'primary','secondary','tertiary',this kind of type road network respectively, how should I do?

OSMnx automatically gets the highway tag. The network_type='drive' argument means that OSMnx will download all the drivable roads within your geography of interest (Zurich). It then constructs a networkx multidigraph of the network. The graph's edges contain attributes, including each's OSM highway type. You can then loop through the edges and inspect their highway values or dump the graph to a geopandas geodataframe to work with it that way if you prefer, as described in the documentation.

Alternatively, if you want a network comprising only certain highway types in the OSM roads hierarchy, see this question and answer.

gboeing
  • 5,691
  • 2
  • 15
  • 41