Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
cat line-delimitted-geo-data.json | node to-collection.js > valid-geojson.json
var fs = require('fs');
var byline = require('byline');
var through2 = require('through2');
// write beginning of featurecollection
process.stdout.write('{"type":"FeatureCollection","features":[');
var first = true;
process.stdin
.pipe(byline.createStream())
.pipe(through2(function(chunk, enc, next){
if (first) process.stdout.write(chunk.toString());
else process.stdout.write(','+chunk.toString());
first = false;
next();
}))
.on('finish', function(){
process.stdout.write(']}\n');
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment