0

I'm new to OSMnx / Overpass queries. I'm trying to pull data on rail networks in global cities. I'm using the script in Python below to pull rail data in London, for example.

There are a number of sub-categories within railway infrastructure (eg, rail, light rail, tram, etc). I wondered if there is any way to see the kind of tags/sub categories used within the data I have pulled.

import osmnx as ox
G = ox.graph_from_point((y,x), 
                        distance = 20000,
                        distance_type = 'bbox', 
                        infrastructure = 'way["railway"~"rail"]',
                        network_type = 'none',
                        )

ox.plot_graph(G)

I know I could also individually go through each subcategory using 'way["railway"~"subway"]' for example, but I wondered if there was way of somehow query the actual multigraph to figure this out?

0

You can peruse what railway tag/values you got by adding "railway" as a tag to retain in the graph, using the ox.config function:

import osmnx as ox
utw = ox.settings.useful_tags_way + ['railway']
ox.config(use_cache=True, log_console=True, useful_tags_way=utw)
G = ox.graph_from_address('London, UK', dist=5000, custom_filter='["railway"]')
ox.graph_to_gdfs(G, nodes=False)['railway'].value_counts()

Also note that the old infrastructure param was deprecated and replaced by the custom_filter param in a previous release.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.