Route Information
The downloaded OSM data contains information about the position of railway switches, level crossings or railway signals and also about the position of railway switches, level crossings or railway signals. This code shows how to search for a specific railway line, retrieve and plot the switches on this line.
[1]:
import pyridy
[2]:
path = "../ridy_data"
campaign = pyridy.Campaign(folder=path, download_osm_data=True, railway_types=["rail"], osm_recurse_type=">")
[WinError 10061] Es konnte keine Verbindung hergestellt werden, da der Zielcomputer die Verbindung verweigerte
[WinError 10060] Ein Verbindungsversuch ist fehlgeschlagen, da die Gegenstelle nach einer bestimmten Zeitspanne nicht richtig reagiert hat, oder die hergestellte Verbindung war fehlerhaft, da der verbundene Host nicht reagiert hat
[3]:
campaign.osm.get_railway_line("RE1") # Search for a specific railway line
re1_aachen_köln = campaign.osm.get_railway_line("RE1")[1]
re1_switches = campaign.osm.get_switches_for_railway_line(re1_aachen_köln)
Plot retrieved switches onto the Map
[4]:
from ipyleaflet import Icon, Marker
m = campaign.create_map(show_railway_elements=False)
for sw in re1_switches:
icon = Icon(icon_url='https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-black.png',
shadow_url='https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
icon_size=[25, 41],
icon_anchor=[12, 41],
popup_anchor=[1, -34],
shadow_size=[41, 41])
marker = Marker(location=(sw.lat, sw.lon), draggable=False, icon=icon)
m.add_layer(marker)
m
(50.90696334838867, 6.762060165405273)