geojson-stream
stream features into and out of geojson
Last updated 8 years ago by tmcw .
BSD-2-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ npm install geojson-stream 
SYNC missed versions from official npm registry.

geojson-stream

Greenkeeper badge build status

Stream features into and out of GeoJSON objects and Feature Collections. Little more than 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);

Current Tags

  • 0.1.0                                ...           latest (8 years ago)

3 Versions

  • 0.1.0                                ...           8 years ago
  • 0.0.1                                ...           11 years ago
  • 0.0.0                                ...           13 years ago
Maintainers (1)
Downloads
Total 3
Today 0
This Week 0
This Month 3
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (3)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE