Browser: http://bl.ocks.org/nrenner/cdb6e84562a9c183a310
Node.js:
git clone https://gist.github.com/cdb6e84562a9c183a310.git
cd cdb6e84562a9c183a310
npm install
wget http://norbertrenner.de/share/testdata.osm.pbf
node index.js
Browser: http://bl.ocks.org/nrenner/cdb6e84562a9c183a310
Node.js:
git clone https://gist.github.com/cdb6e84562a9c183a310.git
cd cdb6e84562a9c183a310
npm install
wget http://norbertrenner.de/share/testdata.osm.pbf
node index.js
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>OSM PBF to GeoJSON example (osm-read + osmtogeojson)</title> | |
<meta charset="utf-8"/> | |
</head> | |
<body> | |
<pre id="log" style="max-height: 480px; overflow-y: auto;"></pre> | |
<script src="http://nrenner.github.io/osmtogeojson/pbftogeojson.js"></script> | |
<script> | |
(function() { | |
function get(url, callback) { | |
var xhr = new XMLHttpRequest(); | |
xhr.open('GET', url, true); | |
xhr.responseType = 'arraybuffer'; | |
xhr.onload = function(evt) { | |
callback(this.response); | |
}; | |
xhr.send(); | |
} | |
function convert(pbf) { | |
osmtogeojson(pbf, null, function(err, geojson) { | |
document.getElementById('log').textContent = JSON.stringify(geojson, null, 2); | |
}); | |
} | |
get('http://norbertrenner.de/share/testdata.osm.pbf', convert); | |
})(); | |
</script> | |
</body> | |
</html> |
var osmtogeojson = require('osmtogeojson'); | |
var parseOsmPbf = require('./node_modules/osmtogeojson/parse_osmpbf.js'); | |
parseOsmPbf('testdata.osm.pbf', function(err, data) { | |
var geojson = osmtogeojson(data); | |
console.log(JSON.stringify(geojson, null, 2)); | |
}); |
{ | |
"main": "index.js", | |
"dependencies": { | |
"osmtogeojson": "nrenner/osmtogeojson#gh-pages" | |
} | |
} |