https://github.com/derhuerst/extract-gtfs-shapes
Extract shapes from a GTFS dataset.
https://github.com/derhuerst/extract-gtfs-shapes
cli geojson gtfs public-transport transit
Last synced: 15 days ago
JSON representation
Extract shapes from a GTFS dataset.
- Host: GitHub
- URL: https://github.com/derhuerst/extract-gtfs-shapes
- Owner: derhuerst
- License: isc
- Created: 2021-02-25T15:25:00.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-05-20T16:21:33.000Z (almost 4 years ago)
- Last Synced: 2025-04-09T18:57:04.115Z (20 days ago)
- Topics: cli, geojson, gtfs, public-transport, transit
- Language: JavaScript
- Homepage: https://github.com/derhuerst/extract-gtfs-shapes#extract-gtfs-shapes
- Size: 21.5 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# extract-gtfs-shapes
Command line tool to **extract [shapes](https://gtfs.org/reference/static#shapestxt) from a [GTFS](https://gtfs.org) dataset.**
[](https://www.npmjs.com/package/extract-gtfs-shapes)


[](https://github.com/sponsors/derhuerst)
[](https://twitter.com/derhuerst)## Installation
```shell
npm install -g extract-gtfs-shapes
```## Usage
```
Usage:
extract-gtfs-shapes
Options:
--concurrency -c How many files to write in parallel. Default: 32
--quiet -q Don't log stats.
Examples:
extract-gtfs-shapes -c 50 data/gtfs/shapes.txt shapes
cat data/gtfs/shapes.txt | extract-gtfs-shapes - shapes
Notes:
extract-gtfs-shapes needs the GTFS shapes.txt to be sorted by
1. shape_id, alphanumerically
2. shape_pt_sequence, numerically
You can use Miller (https://miller.readthedocs.io/) and the
Unix tool sponge to do this:
mlr --csv sort -f shape_id -n shape_pt_sequence \
shapes.txt | sponge shapes.txt
```### from JavaScript
Let's build a simple (and slower) clone of the the `extract-gtfs-shapes` CLI tool documented above:
```js
const {writeFile} = require('fs/promises')
const extractGTFSShapes = require('extract-gtfs-shapes')const processShape = async (shapeId, shape) => {
await writeFile(shapeId + 'geo.json', shape)
}
await extractGTFSShapes('path/to/shapes.txt', processShape)
```## Contributing
If you have a question or need support using `extract-gtfs-shapes`, 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-shapes/issues).