I'm new to overpass queries. I'm trying to write a python script to pull data on the length of rail in major global cities. I am having a problem in the length of track (using
osmnx.basic_stats(G)) seems abnormally large.
I have a two questions:
- For a line of track (running in two directions side by side), it looks like overpass returns two tracks for each direction (eg, four lines of track in total). See this screenshot below in London.
However, for a subway, overpass returns a single line of track in each direction. See screenshot below.
To calculate the total length of track then, is the best way to do this simply to collect these differently and account for these differences by dividing the length of rail track by 2?
- My second question is, what would be an appropriate query to remove disused tracks and industrial tracks. You can see the OSM Railway tag guide here.
FYI, my code to collect the data is as follows:
import osmnx as ox # Pull multigraph using Londons lat/long G = ox.graph_from_point((51.5073509,-0.1277583), distance = 20000, distance_type = 'bbox', infrastructure = 'way["railway"~"rail"]', network_type = 'none', ) # Print length of track in KM print(ox.basic_stats(G)['edge_length_total'] / 1000) # Visualise the data that has been pulled ox.plot_graph_folium(G)