{"id":15592192,"url":"https://github.com/derhuerst/extract-gtfs-pathways","last_synced_at":"2025-04-15T05:02:13.904Z","repository":{"id":48332543,"uuid":"349580128","full_name":"derhuerst/extract-gtfs-pathways","owner":"derhuerst","description":"Command-line tool to extract pathways from a GTFS dataset.","archived":false,"fork":false,"pushed_at":"2024-07-01T14:11:41.000Z","size":59,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T16:11:55.167Z","etag":null,"topics":["accessibility","cli","geojson","gtfs","pathways","public-transport","transit"],"latest_commit_sha":null,"homepage":"https://github.com/derhuerst/extract-gtfs-pathways#extract-gtfs-pathways","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/derhuerst.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"liberapay":"derhuerst","patreon":"derhuerst","github":"derhuerst"}},"created_at":"2021-03-19T23:29:09.000Z","updated_at":"2024-12-01T12:35:37.000Z","dependencies_parsed_at":"2024-01-11T19:16:02.536Z","dependency_job_id":"1693452d-9449-408a-b15a-4c945071fadf","html_url":"https://github.com/derhuerst/extract-gtfs-pathways","commit_stats":{"total_commits":24,"total_committers":1,"mean_commits":24.0,"dds":0.0,"last_synced_commit":"752f1f198d6966082ec8f1a8339525b371c5b90e"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derhuerst%2Fextract-gtfs-pathways","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derhuerst%2Fextract-gtfs-pathways/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derhuerst%2Fextract-gtfs-pathways/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derhuerst%2Fextract-gtfs-pathways/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/derhuerst","download_url":"https://codeload.github.com/derhuerst/extract-gtfs-pathways/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249010212,"owners_count":21197797,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["accessibility","cli","geojson","gtfs","pathways","public-transport","transit"],"created_at":"2024-10-02T23:57:53.649Z","updated_at":"2025-04-15T05:02:13.869Z","avatar_url":"https://github.com/derhuerst.png","language":"JavaScript","funding_links":["https://liberapay.com/derhuerst","https://patreon.com/derhuerst","https://github.com/sponsors/derhuerst"],"categories":["Producing Data","Uncategorized"],"sub_categories":["GTFS","Uncategorized"],"readme":"# extract-gtfs-pathways\n\nCommand line tool to **extract [pathways](https://gtfs.org/reference/static#pathwaystxt) as [GeoJSON](https://geojson.org) from a [GTFS](https://gtfs.org) dataset.**\n\n[![npm version](https://img.shields.io/npm/v/extract-gtfs-pathways.svg)](https://www.npmjs.com/package/extract-gtfs-pathways)\n![ISC-licensed](https://img.shields.io/github/license/derhuerst/extract-gtfs-pathways.svg)\n![minimum Node.js version](https://img.shields.io/node/v/extract-gtfs-pathways.svg)\n[![support me via GitHub Sponsors](https://img.shields.io/badge/support%20me-donate-fa7664.svg)](https://github.com/sponsors/derhuerst)\n[![chat with me on Twitter](https://img.shields.io/badge/chat%20with%20me-on%20Twitter-1da1f2.svg)](https://twitter.com/derhuerst)\n\n\n## Installation\n\n```shell\nnpm install -g extract-gtfs-pathways\n```\n\n\n## Usage\n\n```\nUsage:\n    extract-gtfs-pathways \u003cpath-to-pathways-file\u003e \u003cpath-to-stops-file\u003e \u003coutput-directory\u003e\nOptions:\n    --quiet          -q  Don't log the written files.\n    --pathway-props -f  A JS function to determine additional pathway properties.\n                           Example: pw =\u003e ({isWalking: pw.pathway_mode === '1'})\n                           Note: The argument will be eval-ed!\n    --node-props    -F  A JS function to determine additional node properties.\n                           Example: n =\u003e ({isFoo: n.stop_id === 'foo'})\n                           Note: The argument will be eval-ed!\nExamples:\n    unzip -j gtfs.zip -d data/gtfs\n    mkdir extracted-pathways\n    extract-gtfs-pathways data/gtfs/pathways.txt data/gtfs/stops.txt extracted-pathways\nNotes:\n    This tool will read a reduced form of stops.txt into memory.\n\n    stops.txt needs to be sorted by\n    1. parent_station: lexically ascending, empty first\n    2. location_type: numerically descending, empty first\n    You can use Miller (https://miller.readthedocs.io/) and the\n    Unix tool sponge to do this:\n    mlr --csv sort -f parent_station -nr location_type \\\n      stops.txt | sponge stops.txt\n```\n\n### with Docker\n\nYou can use the [`docker.io/derhuerst/extract-gtfs-pathways` Docker image](https://hub.docker.com/r/docker.io/derhuerst/extract-gtfs-pathways).\n\nRemember to mount (using `-v`) the directory you're passing as `\u003coutput-directory\u003e` (see above), otherwise the file will be created within the Docker container's virtual file system (and removed after the extraction has finished).\n\n```shell\nunzip -j gtfs.zip -d gtfs # directory with GTFS input\nmkdir extracted-pathways # output directory\ndocker run -it --rm \\\n    -v $PWD/gtfs:/gtfs \\\n    -v $PWD/extracted-pathways:/extracted-pathways\n    docker.io/derhuerst/extract-gtfs-pathways /gtfs/pathways.txt /gtfs/stops.txt /extracted-pathways\n```\n\n### pro tip: customize color nodes \u0026 pathways\n\nBy default, `extract-gtfs-pathways` adds some style properties to the generated features, following the [Mapbox GL JS](https://docs.mapbox.com/mapbox-gl-js/api/) naming scheme, e.g. `line-color`, `line-width` \u0026 `circle-radius`. If you open them with a tool that supports these style properties – e.g. [view-geojson](https://npmjs.com/package/view-geojson), it will be easier to tell the nodes \u0026 pathways apart.\n\nYou can use `--pathway-props`/`-f` and `--node-props`/`-F` to customize the pathways' and nodes' properties, respectively. As an example, let's define two functions that override some default properties:\n\n```js\nconst WALKWAY = '1'\nconst ESCALATOR = '4'\nconst ELEVATOR = '5'\nconst pwOpacities = {[WALKWAY]: .3, [ESCALATOR]: .8, [ELEVATOR]: 1}\nconst pathwayProps = (pw) =\u003e ({\n\t'line-opacity': pwOpacities[pw.pathway_mode] || .5,\n\t'line-width': 2,\n})\n\nconst STOP = '0' // or empty\nconst ENTRANCE_EXIT = '2'\nconst BOARDING_AREA = '4'\nconst nodeColors = {\n    [STOP]: '#ff0000', '': '#ff0000',\n    [ENTRANCE_EXIT]: '#00ff00',\n    [BOARDING_AREA]: '#0000ff',\n}\nconst nodeProps = (n) =\u003e ({\n\t'circle-color': nodeColors[n.location_type] || '#444444',\n})\n```\n\nWe minify the functions and declare them as Bash variables:\n\ntodo: make these the default?\n\n```bash\npw_props='pw =\u003e ({\"line-opacity\": {\"1\": .3, \"4\": .8, \"5\": 1}[pw.pathway_mode] || .5, \"line-width\": 2})'\nnode_props='n =\u003e ({\"circle-color\": {\"0\": \"#ff0000\", \"\": \"#ff0000\", \"2\": \"#00ff00\", \"4\": \"#0000ff\"}[n.location_type] || \"#444444\"})'\n```\n\nThen, we can use them:\n\n```bash\nextract-gtfs-pathways --pathway-props \"$pw_props\" --node-props \"$node_props\" gtfs/pathways.txt gtfs/stops.txt out\n```\n\nAlternatively, we can also use `geojson.io`'s naming scheme:\n\n```bash\npw_props='pw =\u003e ({\"stroke-opacity\": {\"1\": .3, \"4\": .8, \"5\": 1}[pw.pathway_mode] || .5, \"stroke-width\": 2})'\nnode_props='n =\u003e ({\"marker-color\": {\"0\": \"#ff0000\", \"\": \"#ff0000\", \"2\": \"#00ff00\", \"4\": \"#0000ff\"}[n.location_type] || \"#444444\"})'\n```\n\n## Related\n\n- [view-geojson](https://github.com/finnp/view-geojson) – View an GeoJSON in the browser that has been piped into it.\n- [extract-gtfs-shapes](https://github.com/derhuerst/extract-gtfs-shapes) – Command-line tool to extract shapes from a GTFS dataset.\n- [Awesome GTFS: Frameworks and Libraries](https://github.com/andredarcie/awesome-gtfs#frameworks-and-libraries) – A collection of libraries for working with GTFS.\n\n\n## Contributing\n\nIf you have a question or need support using `extract-gtfs-pathways`, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, use [the issues page](https://github.com/derhuerst/extract-gtfs-pathways/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderhuerst%2Fextract-gtfs-pathways","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fderhuerst%2Fextract-gtfs-pathways","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderhuerst%2Fextract-gtfs-pathways/lists"}