Package: osm2rail
OSM2RailAn open-source education tool for constructing modeling datasets of railway transportationAuthors: Jiawei Lu, Qian Fu, Zanyang Cui, Dr. Junhua ChenEmail:jiaweil9@asu.edu,q.fu@bham.ac.uk,zanyangcui@outlook.com,cjh@bjtu.edu.cnIntroductionThe python tool of OSM2Rail is an integrated and enhanced version of two python packages, namelyOSM2GMNSandPydriosm. The former aims to convertOpenStreetMapdata to generic node and link files in GMNS format, and the latter aims to enable a batch process of downloading, reading and PostgreSQL-based I/O of OpenStreetMap data.OSM2GMNS is currently developed and maintained by Jiawei Lu and Dr. Xuesong Zhou at Arizona State University. PyDriosm published by Dr. Qian Fu at Birmingham Centre for Railway Research and Education, University of Birmingham, is an open-source tool for researchers or practitioners to easily download and read OSM map data in popular file formats such as protocolbuffer binary format (PBF) and shapefile, which are available for free download from Geofabrik and BBBike. This package also provides a convenient way for PostgreSQL-based I/O and storage of parsed OSM data.Integrating the data conversion and online data downloading capabilities from the above 2 packages, OSM2Rail allows users to rapidly obtain OSM data for a given set of areas and convert them to node, link, and poi files for further system modeling and optimization. Users are recommended to download OSM map data in .osm or .osm.pbf format and convert them to commonly used csv files.Requirementsbs4osmiumshapelymatplotlibfuzzywuzzyshapelypandasnumpyrequestsFeaturesDownload and parse OpenStreetMap (OSM) data in popular file formats such as protocolbuffer binary format (.osm.pbf) and XML format (.osm)Export railway elements from OSM data to node, link and poi filesSupport exporting railway elements with specified namesExport railway elements as csv file in GMNS formatSupport QGIS to open output filesInstallationpipinstallosm2railNote
For Windows users, the pip method might fail to install some dependencies. If errors occur when you try to install any of those dependencies, try instead to pip install their .whl files, which can be downloaded from the Unoffical Windows Binaries forPython Extension Packages.Quick startStep1: download OSM data from OSMimportosm2railasorlsubarea_name='IHB Blue Island Yard'download_dir='./osmfile'osm_file=orl.download_osm_data_from_overpass(subarea_names=subarea_name,download_dir=download_dir,ret_download_path=True)output:The box of IHB_Blue_Island_Yard is ['41.6372039', '41.642362', '-87.6599743', '-87.6294597']
download progress：0.64 MB(0.64 MB)
Done.Step2: convert OSM data in .osm format to GMNS-rail network filesnet=orl.get_network_from_file(filename=osm_file[0],POIs=True,check_boundary=True)Step3: visualize rail networkorl.show_network(net)output:Step4: save rail network to CSV fileorl.save_network(net,output_folder='./csvfile')Advance UsageStep1: prepare an osm map fileHere we manually downloaded the map file of the city of London through BBBike.Step2: specify the railway element name and parse the railnetwork.# net=orl.get_network_from_file(filename='./osmfile/London.osm',POIs=True)# specify the railway elementnet=orl.get_network_from_file(filename='./osmfile/London.osm',POIs=True,target_elements=['South London Line'])Step3: visualize rail networkorl.show_network(net)output:All rail lines:South London Line:Step4: save rail network to CSV fileorl.save_network(net,output_folder='./csvfile')Sample NetworksBeijing-Tianjin Intercity RailwayBeijing South Railway StationShanghai Hongqiao Railway StationFrankfurtBNSF Argentine YardUpdate log2022.04.06-v0.0.6Added: Add the 'target_elements' field to parse the rail network with the given names.Changed: Change 'strict_mode' to 'check_boundary'.Changed: Adjust railway key fields.LicenseApache Software License (Apache License 2.0).