# geojson-stream

> stream features into and out of geojson

Latest version **0.1.0** (published 2019-01-16) · BSD-2-Clause license · 0 weekly downloads

## Install

```sh
npm install geojson-stream
pnpm add geojson-stream
yarn add geojson-stream
bun add geojson-stream
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2019-01-16 |
| First published | 2013-10-17 |
| Weekly downloads | 0 |
| License | BSD-2-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 101.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 54 |
| Author | Tom MacWright |
| Maintainers | tmcw |
| Keywords | geojson, stream, maps, json, pipe |

## Links

- npm: https://www.npmjs.com/package/geojson-stream
- Repository: https://github.com/tmcw/geojson-stream
- Homepage: https://github.com/tmcw/geojson-stream#readme
- Issues: https://github.com/tmcw/geojson-stream/issues
- npm.io page: https://npm.io/package/geojson-stream

## Dependencies (2)

- [through](https://npm.io/package/through.md) ^2.3.4
- [JSONStream](https://npm.io/package/JSONStream.md) ^1.0.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.1.0 (latest) — 2019-01-16
- 0.0.1 — 2015-11-04
- 0.0.0 — 2013-10-17

## README

# geojson-stream

[![Greenkeeper badge](https://badges.greenkeeper.io/tmcw/geojson-stream.svg)](https://greenkeeper.io/)
[![build status](https://secure.travis-ci.org/tmcw/geojson-stream.svg)](http://travis-ci.org/tmcw/geojson-stream)

Stream features into and out of [GeoJSON](http://geojson.org/) objects
and Feature Collections. Little more than [JSONStream](https://github.com/dominictarr/JSONStream)
with pre-filled settings.

## usage

    npm install --save geojson-stream

## api

### `geojsonStream.stringify()`

Returns a transform stream that accepts GeoJSON Feature objects and emits
a stringified FeatureCollection.

### `geojsonStream.parse(mapFunc)`

Returns a transform stream that accepts a GeoJSON FeatureCollection as a stream
and emits Feature objects.

`mapFunc(feature, index)` is an optional function which takes a `Feature`, and its zero-based index in the `FeatureCollection` and returns either a `Feature`, or null/undefined 
if the feature should be omitted from output.

## example

```
const geojsonStream = require('geojson-stream');
const fs = require('fs');
const out = fs.createWriteStream('buildings-with-id.geojson');
fs
    .createReadStream(`buildings.geojson`)
    .pipe(geojsonStream.parse((building, index) => {
        if (building.geometry.coordinates === null) {
            return null;
        }
        building.id = index;
        return building;
    }))
    .pipe(geojsonStream.stringify())
    .pipe(out);
```

---
_Source: https://npm.io/package/geojson-stream · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
