Skip to content

Instantly share code, notes, and snippets.

@tmcw
Created October 17, 2013 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmcw/7031780 to your computer and use it in GitHub Desktop.
Save tmcw/7031780 to your computer and use it in GitHub Desktop.
var osmium = require('./'),
fs = require('fs'),
geojsonStream = require('geojson-stream');
var fileOut = fs.createWriteStream('nodes.geojson');
var geojsonOut = geojsonStream.stringify();
geojsonOut.pipe(fileOut);
// uncomment this line, and install geojsonio:
//
// npm install -g geojsonio-cli
//
// and run
//
// node test_stream.js | geojsonio
//
// geojsonOut.pipe(process.stdout);
var handler = new osmium.Handler();
var nodes = 0;
handler.on('node',function(node) {
geojsonOut.write({
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [node.lon, node.lat]
},
properties: {}
});
});
handler.on('done',function() {
geojsonOut.end();
});
var reader = new osmium.Reader("winthrop.osm");
reader.apply(handler);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment