Name | gtfs2gmns JSON |
Version |
0.2.3
JSON |
| download |
home_page | https://github.com/xyluo25/gtfs2gmns |
Summary | A class-based instance designed for reading, converting, analyzing, and visualizing GTFS data |
upload_time | 2024-07-23 19:28:57 |
maintainer | None |
docs_url | None |
author | Xiangyong Luo, Fang Tang, Xuesong Simon Zhou |
requires_python | >=3.10 |
license | MIT License Copyright (c) 2024 xyluo25 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
general transit feed specification (gtfs)
gmns
visualization
space-time trajectory
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
## GTFS2GMNS
The open-source Python codes (GTFS2GMNS) is released to facilitate researchers and planners to construct the multi-modal transit networks easily from generic [General Transit Feed Specification (GTFS)](https://gtfs.org/) to the network modeling format in [General Modeling Network Specification (GMNS)](https://github.com/zephyr-data-specs/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 of [GTFS2GMNS Users' Guide](https://docs.google.com/document/d/1-A2g4ZjJu-gzusEKcSoOXzr95S3tv7sj/edit?usp=sharing&ouid=112385243549486266715&rtpof=true&sd=true).
## Getting Started
### *Download GTFS Data*
On TransitFeed [homepage](https://transitfeeds.com/), 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.txt
* route.txt
* trip.txt
* stop_times.txt
* agency.txt
GTFS2GMNS can handle the transit data from several agencies. Users need to configure different sub-files in the same directory.
## Main Steps
### *Read GTFS data*
**Step 1.1: Read routes.txt**
- route_id, route_long_name, route_short_name, route_url, route_type
**Step 1.2: Read stop.txt**
- stop_id, stop_lat, stop_lon, direction, location_type, position, stop_code, stop_name, zone_id
**Step 1.3: Read trips.txt**
- trip_id, route_id, service_id, block_id, direction_id, shape_id, trip_type
- and create the directed_route_id by combining route_id and direction_id
**Step 1.4: Read stop_times.txt**
- trip_id, stop_id, arrival_time, deaprture_time, stop_sequence
- create directed_route_stop_id by combining directed_route_id and stop_id through the trip_id
> Note: 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_id
- return the arrival_time for every stop
### *Building service network*
**Step 2.1 Create physical nodes**
- physical node is the original stop in standard GTFS
**Step 2.2 Create directed route stop vertexes**
- add route stop vertexes. the node_id of route stop nodes starts from 100001
> Note: 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 node
- add 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 implemented
**Step 2.3 Create physical arcs**
- add physical links between each physical node pair of each trip
**Step 2.4 Create service arcs**
- add service links between each route stop pair of each trip
## Visualization
You can visualize generated networks using [NeXTA](https://github.com/xzhou99/NeXTA-GMNS) or [QGIS](https://qgis.org/).
## Quick Tutorial
### Introducing Functional Tools within GTFS2GMNS
GTFS2GMNS 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 GTFS2GMNS
- **gtfs_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 selection
- **gtfs_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 True
### *Code Example*
#### Loading gtfs data
```python
from gtfs2gmns import GTFS2GMNS
if __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 nodes
```python
import gtfs2gmns as gg
path_zone = "Path to zone.csv" # please make sure you have zone_id, x_coord, y_coord in columns
path_node = "Path to node.csv" # please make sure you have node_id, x_coord, y_coord in columns
radius = 100 # unit in meters
k_closest = 0 # if 0, generate all accessible links within radius. if 1, closest link within the radius...
access_links = gg.generate_access_links(path_zone, path_node, radius, k_closest)
access_links.to_csv("access_link.csv", index=False)
```
### Functions and Attributes
| func_type | func_name | Python example | Input | Output | Remark |
| :-------------- | :----------------------------- | :--------------- | ------- | ----------- | --------------------------------------------------------------- |
| read-show | agency | `gg.agency` | NA | DataFrame | This attribute load and return agency data from source folder |
| | calendar | `gg.calendar` | | | |
| | calendar_dates | | | | |
| | fare_attributes | | | | |
| | fare_rules | | | | |
| | feed_info | | | | |
| | frequencies | | | | |
| | routes | | | | |
| | shapes | | | | |
| | stops | | | | |
| | stop_times | | | | |
| | trips | | | | |
| | transfers | | | | |
| | timepoints | | | | |
| | timepoint_times | | | | |
| | trip_routes | | | | |
| | stops_freq | | | | |
| | routes_freq | | | | |
| | rute_segments | | | | |
| | route_segment_speed | | | | |
| | vis_stops_freq | | | | |
| analysis | vis_routes_fres | | | | |
| | vis_route_segment_speed | | | | |
| | vis_route_segment_runtime | | | | |
| | vis_route_stop_speed_heatmap | | | | |
| | vis_spacetime_trajectory | | | | |
| | equity_alanysis | | | | |
| | accessibility_analysis | | | | |
| | load_gtfs | | | | |
| | gen_gmns_node_link | | | | |
| | | | | | |
| | | | | | |
| visualization | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
## Upcoming Features
- [ ] Output service and trace files.
- [ ] Set the time period and add vdf_fftt and vdf_freq fields in link files.
- [ ] Add Visualization functions
- [ ] Stops
- [ ] Routes
- [ ] ...
## Citing gtfs2gmns
If 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}
}
```
```bibtex
@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}
}
```
```
Luo, X., Tang, F, Wang, H and Zhou, X. (2021, April 4). GTFS2GMNS. Retrieved from https://github.com/xyluo25/gtfs2gmns
```
Raw data
{
"_id": null,
"home_page": "https://github.com/xyluo25/gtfs2gmns",
"name": "gtfs2gmns",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "Xiangyong Luo <luoxiangyong01@gmail.com>",
"keywords": "General Transit Feed Specification (GTFS), GMNS, Visualization, Space-time Trajectory",
"author": "Xiangyong Luo, Fang Tang, Xuesong Simon Zhou",
"author_email": "Xiangyong Luo <luoxiangyong01@gmail.com>, Xuesong Simon Zhou <xzhou74@asu.com>, Fang Tang <fangt@asu.edu>",
"download_url": "https://files.pythonhosted.org/packages/c9/8a/5fb31a86298d4a239164bd179527704c78588e79a21972cbb67305d90084/gtfs2gmns-0.2.3.tar.gz",
"platform": "all",
"description": "## GTFS2GMNS\r\n\r\nThe open-source Python codes (GTFS2GMNS) is released to facilitate researchers and planners to construct the multi-modal transit networks easily from generic [General Transit Feed Specification (GTFS)](https://gtfs.org/) to the network modeling format in [General Modeling Network Specification (GMNS)](https://github.com/zephyr-data-specs/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.\r\n\r\nYour comments will be valuable for code review and improvement. Please feel free to add your comments to our Google document of [GTFS2GMNS Users' Guide](https://docs.google.com/document/d/1-A2g4ZjJu-gzusEKcSoOXzr95S3tv7sj/edit?usp=sharing&ouid=112385243549486266715&rtpof=true&sd=true).\r\n\r\n## Getting Started\r\n\r\n### *Download GTFS Data*\r\n\r\nOn TransitFeed [homepage](https://transitfeeds.com/), 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.\r\n\r\n* stop.txt\r\n* route.txt\r\n* trip.txt\r\n* stop_times.txt\r\n* agency.txt\r\n\r\nGTFS2GMNS can handle the transit data from several agencies. Users need to configure different sub-files in the same directory.\r\n\r\n## Main Steps\r\n\r\n### *Read GTFS data*\r\n\r\n**Step 1.1: Read routes.txt**\r\n\r\n- route_id, route_long_name, route_short_name, route_url, route_type\r\n\r\n**Step 1.2: Read stop.txt**\r\n\r\n- stop_id, stop_lat, stop_lon, direction, location_type, position, stop_code, stop_name, zone_id\r\n\r\n**Step 1.3: Read trips.txt**\r\n\r\n- trip_id, route_id, service_id, block_id, direction_id, shape_id, trip_type\r\n- and create the directed_route_id by combining route_id and direction_id\r\n\r\n**Step 1.4: Read stop_times.txt**\r\n\r\n- trip_id, stop_id, arrival_time, deaprture_time, stop_sequence\r\n- create directed_route_stop_id by combining directed_route_id and stop_id through the trip_id\r\n\r\n > Note: the function needs to skip this record if trip_id is not defined, and link the virtual stop id with corresponding physical stop id.\r\n >\r\n- fetch the geometry of the direction_route_stop_id\r\n- return the arrival_time for every stop\r\n\r\n### *Building service network*\r\n\r\n**Step 2.1 Create physical nodes**\r\n\r\n- physical node is the original stop in standard GTFS\r\n\r\n**Step 2.2 Create directed route stop vertexes**\r\n\r\n- add route stop vertexes. the node_id of route stop nodes starts from 100001\r\n\r\n > Note: the route stop vertex the programing create nearby the corresponding physical node, to make some offset.\r\n >\r\n- add entrance link from physical node to route stop node\r\n- add 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 implemented\r\n\r\n**Step 2.3 Create physical arcs**\r\n\r\n- add physical links between each physical node pair of each trip\r\n\r\n**Step 2.4 Create service arcs**\r\n\r\n- add service links between each route stop pair of each trip\r\n\r\n## Visualization\r\n\r\nYou can visualize generated networks using [NeXTA](https://github.com/xzhou99/NeXTA-GMNS) or [QGIS](https://qgis.org/).\r\n\r\n## Quick Tutorial\r\n\r\n### Introducing Functional Tools within GTFS2GMNS\r\n\r\nGTFS2GMNS 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.\r\n\r\n### Input for class GTFS2GMNS\r\n\r\n- **gtfs_input_dir** : str, the dir store GTFS data. **GTFS2GMNS is capable of reading multiple GTFS data sets.**\r\n- **time_period**: str, the time period sprcified (for data selection), default is \"07:00:00_08:00:00\"\r\n- **date_period**: list, user can specified exact data or dates for selection\r\n- **gtfs_output_dir**: str, the output folder to save data. defalut is \"\"\r\n- **isSaveToCSV**: bool, whether to save gmns node and link to local machine, default is True\r\n\r\n### *Code Example*\r\n\r\n#### Loading gtfs data\r\n\r\n```python\r\nfrom gtfs2gmns import GTFS2GMNS\r\n\r\nif __name__ == \"__main__\":\r\n gtfs_input_dir = r\"Your-Path-Folder-To-GTFS-Data\"\r\n\r\n # Explain: GMNS2GMNS is capable of reading multiple GTFS data sets\r\n \"\"\"\r\n\t--root folder\r\n\t -- subfolder (GTFS data of agency 1)\r\n\t -- subfolder (GTFS data of agency 2)\r\n\t -- subfolder (GTFS data of agency 3)\r\n\t -- ...\r\n\tthen, assign gtfs_input_foler = root folder\r\n \"\"\"\r\n\r\n time_period = \"00:00:00_23:59:59\"\r\n date_period = []\r\n\r\n gg = GTFS2GMNS(gtfs_input_dir, time_period, date_period, gtfs_output_dir=\"\", isSaveToCSV=False)\r\n\r\n```\r\n\r\n#### Generate access line between zones to nodes\r\n\r\n```python\r\n\r\nimport gtfs2gmns as gg\r\n\r\npath_zone = \"Path to zone.csv\" # please make sure you have zone_id, x_coord, y_coord in columns\r\npath_node = \"Path to node.csv\" # please make sure you have node_id, x_coord, y_coord in columns\r\n\r\nradius = 100 # unit in meters\r\nk_closest = 0 # if 0, generate all accessible links within radius. if 1, closest link within the radius...\r\n\r\naccess_links = gg.generate_access_links(path_zone, path_node, radius, k_closest)\r\n\r\naccess_links.to_csv(\"access_link.csv\", index=False)\r\n\r\n```\r\n\r\n### Functions and Attributes\r\n\r\n\r\n| func_type | func_name | Python example | Input | Output | Remark |\r\n| :-------------- | :----------------------------- | :--------------- | ------- | ----------- | --------------------------------------------------------------- |\r\n| read-show | agency | `gg.agency` | NA | DataFrame | This attribute load and return agency data from source folder |\r\n| | calendar | `gg.calendar` | | | |\r\n| | calendar_dates | | | | |\r\n| | fare_attributes | | | | |\r\n| | fare_rules | | | | |\r\n| | feed_info | | | | |\r\n| | frequencies | | | | |\r\n| | routes | | | | |\r\n| | shapes | | | | |\r\n| | stops | | | | |\r\n| | stop_times | | | | |\r\n| | trips | | | | |\r\n| | transfers | | | | |\r\n| | timepoints | | | | |\r\n| | timepoint_times | | | | |\r\n| | trip_routes | | | | |\r\n| | stops_freq | | | | |\r\n| | routes_freq | | | | |\r\n| | rute_segments | | | | |\r\n| | route_segment_speed | | | | |\r\n| | vis_stops_freq | | | | |\r\n| analysis | vis_routes_fres | | | | |\r\n| | vis_route_segment_speed | | | | |\r\n| | vis_route_segment_runtime | | | | |\r\n| | vis_route_stop_speed_heatmap | | | | |\r\n| | vis_spacetime_trajectory | | | | |\r\n| | equity_alanysis | | | | |\r\n| | accessibility_analysis | | | | |\r\n| | load_gtfs | | | | |\r\n| | gen_gmns_node_link | | | | |\r\n| | | | | | |\r\n| | | | | | |\r\n| visualization | | | | | |\r\n| | | | | | |\r\n| | | | | | |\r\n| | | | | | |\r\n| | | | | | |\r\n| | | | | | |\r\n| | | | | | |\r\n| | | | | | |\r\n\r\n## Upcoming Features\r\n\r\n- [ ] Output service and trace files.\r\n- [ ] Set the time period and add vdf_fftt and vdf_freq fields in link files.\r\n- [ ] Add Visualization functions\r\n - [ ] Stops\r\n - [ ] Routes\r\n - [ ] ...\r\n\r\n## Citing gtfs2gmns\r\n\r\nIf you use gtfs2gmns in your research please use the following BibTeX entry:\r\n\r\n```\r\n@misc{gtfs2gmns,\r\n author = {Fang Tang, Xiangyong Luo, Han Wang, Xuesong Zhou},\r\n title = {Connecting Oasis for Transit Deserts: Mathematical Model and Reformulation for Equity-oriented Network Design},\r\n howpublished = {Github},\r\n year = {2023},\r\n url = {https://github.com/xyluo25/gtfs2gmns}\r\n}\r\n```\r\n\r\n```bibtex\r\n@misc{gtfs2gmns,\r\n author = {Xiangyong Luo, Fang Tang, Han Wang, Xuesong Zhou},\r\n title = {gtfs2gmns - A class-based instance designed for reading, converting, analyzing, and visualizing GTFS data.},\r\n howpublished = {Github},\r\n year = {2023},\r\n url = {https://github.com/xyluo25/gtfs2gmns}\r\n}\r\n```\r\n\r\n```\r\nLuo, X., Tang, F, Wang, H and Zhou, X. (2021, April 4). GTFS2GMNS. Retrieved from https://github.com/xyluo25/gtfs2gmns\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2024 xyluo25 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "A class-based instance designed for reading, converting, analyzing, and visualizing GTFS data",
"version": "0.2.3",
"project_urls": {
"Bug Tracker": "https://github.com/xyluo25/gtfs2gmns/issues",
"Contact": "https://github.com/xyluo25/gtfs2gmns",
"Download": "https://www.pepy.tech/projects/gtfs2gmns",
"Homepage": "https://github.com/xyluo25/gtfs2gmns",
"License": "https://github.com/xyluo25/gtfs2gmns/blob/main/LICENSE"
},
"split_keywords": [
"general transit feed specification (gtfs)",
" gmns",
" visualization",
" space-time trajectory"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6f4cc0071693508edbad51c2b07fc54e036908ac9e8d3c94a4edfc79bc065d3d",
"md5": "837451f8070882442300a1f7a3a04643",
"sha256": "52b464d62d44d55cb18caefe21642b6b63ed7c06521dd0bd1d993e6c7f61bd00"
},
"downloads": -1,
"filename": "gtfs2gmns-0.2.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "837451f8070882442300a1f7a3a04643",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 20298,
"upload_time": "2024-07-23T19:28:54",
"upload_time_iso_8601": "2024-07-23T19:28:54.769908Z",
"url": "https://files.pythonhosted.org/packages/6f/4c/c0071693508edbad51c2b07fc54e036908ac9e8d3c94a4edfc79bc065d3d/gtfs2gmns-0.2.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c98a5fb31a86298d4a239164bd179527704c78588e79a21972cbb67305d90084",
"md5": "eecb9195e50a4458f5e1f4acc3a34914",
"sha256": "a29b38693e297b97be84963765ba38eea25a74920d33c04756640ed28040004c"
},
"downloads": -1,
"filename": "gtfs2gmns-0.2.3.tar.gz",
"has_sig": false,
"md5_digest": "eecb9195e50a4458f5e1f4acc3a34914",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 22240,
"upload_time": "2024-07-23T19:28:57",
"upload_time_iso_8601": "2024-07-23T19:28:57.338583Z",
"url": "https://files.pythonhosted.org/packages/c9/8a/5fb31a86298d4a239164bd179527704c78588e79a21972cbb67305d90084/gtfs2gmns-0.2.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-23 19:28:57",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "xyluo25",
"github_project": "gtfs2gmns",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "gtfs2gmns"
}