Package: gtfs2gmns
GTFS2GMNSThe open-source Python codes (GTFS2GMNS) is released to facilitate researchers and planners to construct the multi-modal transit networks easily from genericGeneral Transit Feed Specification (GTFS)to the network modeling format inGeneral Modeling Network Specification (GMNS). The converted physical and service networks in GMNS format are more convenient for network modeling tasks such as transit network routing, traffic flow assignment, simulation and service network optimization.Your comments will be valuable for code review and improvement. Please feel free to add your comments to our Google document ofGTFS2GMNS Users' Guide.Getting StartedDownload GTFS DataOn TransitFeedhomepage, users can browse and download official GTFS  feeds from around the world. Make sure that the following files are present, so that we can proceed.stop.txtroute.txttrip.txtstop_times.txtagency.txtGTFS2GMNS can handle the transit data from several agencies. Users need to configure different sub-files in the same directory. Under thetest/GTFSfolder, a subfolderPheonixwith its owm GTFS data is set up.Convert GTFS Data into GMNS Formatif__name__=='__main__':globalperiod_start_timeglobalperiod_end_timeinput_gtfs_path='GTFS'output_gmns_path='.'time_period_id=1time_period='1200_1300'period_start_time,period_end_time=_hhmm_to_minutes(time_period)gtfs2gmns(input_gtfs_path,output_gmns_path)The input parameterinput_gtfs_pathis the path of GTFS data, and the parameteroutput_gmns_pathis the path of output GMNS files. Users can customize the parametertime_period, such as 12:00 to 13:00.The output files include node.csv and link.csv.Main StepsRead GTFS dataStep 1.1: Read routes.txtroute_id, route_long_name, route_short_name, route_url, route_typeStep 1.2: Read stop.txtstop_id, stop_lat, stop_lon, direction, location_type, position, stop_code, stop_name, zone_idStep 1.3: Read trips.txttrip_id, route_id, service_id, block_id, direction_id, shape_id, trip_typeand create the directed_route_id by combining route_id and direction_idStep 1.4: Read stop_times.txttrip_id, stop_id, arrival_time, deaprture_time, stop_sequencecreate directed_route_stop_id by combining directed_route_id and stop_id through the trip_idNote: the function needs to skip this record if trip_id is not defined, and link the virtual stop id with corresponding physical stop id.fetch the geometry of the direction_route_stop_idreturn the arrival_time for every stopBuilding service networkStep 2.1 Create physical nodesphysical node is the original stop in standard GTFSStep 2.2 Create directed route stop vertexesadd route stop vertexes. the node_id of route stop nodes starts from 100001Note: the route stop vertex the programing create nearby the corresponding physical node, to make some offset.add entrance link from physical node to route stop nodeadd exit link from route stop node to physical node. As they both connect to the physical nodes, the in-station transfer process can be also implementedStep 2.3 Create physical arcsadd physical links between each physical node pair of each tripStep 2.4 Create service arcsadd service links between each route stop pair of each tripVisualizationYou can visualize generated networks usingNeXTAorQGIS.Quick TutorialIntroducing Functional Tools within GTFS2GMNSGTFS2GMNS is a Python package that serves as a class-based instance, specifically designed for reading, converting, analyzing, and visualizing GTFS data. The converted physical and service networks in GMNS format offer enhanced convenience for a variety of networkAg modeling tasks, including transit network routing, traffic flow assignment, simulation, and service network optimization.Input for class GTFS2GMNSgtfs_input_dir:  str, the dir store GTFS data.GTFS2GMNS is capable of reading multiple GTFS data sets.time_period: str, the time period sprcified (for data selection), default is "07:00:00_08:00:00"date_period: list, user can specified exact data or dates for selectiongtfs_output_dir: str, the output folder to save data. defalut is ""isSaveToCSV: bool, whether to save gmns node and link to local machine, default is TrueCode ExampleLoading gtfs datafromgtfs2gmnsimportGTFS2GMNSif__name__=="__main__":gtfs_input_dir=r"Your-Path-Folder-To-GTFS-Data"# Explain: GMNS2GMNS is capable of reading multiple GTFS data sets"""--root folder-- subfolder (GTFS data of agency 1)-- subfolder (GTFS data of agency 2)-- subfolder (GTFS data of agency 3)-- ...then, assign gtfs_input_foler = root folder"""time_period="00:00:00_23:59:59"date_period=[]gg=GTFS2GMNS(gtfs_input_dir,time_period,date_period,gtfs_output_dir="",isSaveToCSV=False)Generate access line between zones to nodesimportgtfs2gmnsasggpath_zone="Path to zone.csv"# please make sure you have zone_id, x_coord, y_coord in columnspath_node="Path to node.csv"# please make sure you have node_id, x_coord, y_coord in columnsradius=100# unit in metersk_closest=0# if 0, generate all accessible links within radius. if 1, closest link within the radius...access_links=gg.generate_access_lins(path_zone,path_node,radius,k_closest)access_links.to_csv("access_link.csv",index=False)Functions and Attributesfunc_typefunc_namePython exampleInputOutputRemarkread-showagencygg.agencyNADataFrameThis attribute load and return agency data from source foldercalendargg.calendarcalendar_datesfare_attributesfare_rulesfeed_infofrequenciesroutesshapesstopsstop_timestripstransferstimepointstimepoint_timestrip_routesstops_freqroutes_freqrute_segmentsroute_segment_speedvis_stops_freqanalysisvis_routes_fresvis_route_segment_speedvis_route_segment_runtimevis_route_stop_speed_heatmapvis_spacetime_trajectoryequity_alanysisaccessibility_analysisload_gtfsgen_gmns_node_linkvisualizationUpcoming FeaturesOutput service and trace files.Set the time period and add vdf_fftt and vdf_freq fields in link files.Add Visualization functionsStopsRoutes...Citing gtfs2gmnsIf you use gtfs2gmns in your research please use the following BibTeX entry:@misc{gtfs2gmns,
  author =       {Fang Tang, Xiangyong Luo, Han Wang, Xuesong Zhou},
  title =        {Connecting Oasis for Transit Deserts: Mathematical Model and Reformulation for Equity-oriented Network Design},
  howpublished = {Github},
  year =         {2023},
  url =          {https://github.com/xyluo25/gtfs2gmns}
}@misc{gtfs2gmns,
  author =       {Xiangyong Luo, Fang Tang, Han Wang, Xuesong Zhou},
  title =        {gtfs2gmns - A class-based instance designed for reading, converting, analyzing, and visualizing GTFS data.},
  howpublished = {Github},
  year =         {2023},
  url =          {https://github.com/xyluo25/gtfs2gmns}
}@misc{gtfs2gmns,
  author =       {Xiangyong Luo, Fang Tang, Han Wang, Xuesong Zhou},
  title =        {gtfs2gmns - A class-based instance designed for reading, converting, analyzing, and visualizing GTFS data.},
  howpublished = {Github},
  year =         {2023},
  url =          {https://github.com/xyluo25/gtfs2gmns}
}