Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 14 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 (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-05-20T16:21:33.000Z (over 3 years ago)
- Last Synced: 2024-12-25T00:30:37.949Z (28 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.**
[![npm version](https://img.shields.io/npm/v/extract-gtfs-shapes.svg)](https://www.npmjs.com/package/extract-gtfs-shapes)
![ISC-licensed](https://img.shields.io/github/license/derhuerst/extract-gtfs-shapes.svg)
![minimum Node.js version](https://img.shields.io/node/v/extract-gtfs-shapes.svg)
[![support me via GitHub Sponsors](https://img.shields.io/badge/support%20me-donate-fa7664.svg)](https://github.com/sponsors/derhuerst)
[![chat with me on Twitter](https://img.shields.io/badge/chat%20with%20me-on%20Twitter-1da1f2.svg)](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).