osm2geojson-lite
A lightweight (not as lightweight as xml2geojson though) yet faster convertor for OSM data whatever in XML or JSON formats to GeoJSON - much faster (the more complex the data source is, the more performance advantages it posesses) than osmtogeojson in most situations - implemented in pure JavaScript without any 3rd party dependency.
History
An internal function inside query-geo-boundary -> stripped to handle OSM XML only xml2geojson-lite -> this library that supports both OSM XML and JSON
Usage
In Node.JS
Installation:
$ npm install osm2geojson-lite
Usage:
const osm2geojson = require('osm2geojson-lite');
let geojson = osm2geojson(osm);
In Browser
<script src='your/path/to/osm2geojson-lite.js'></script>
let geojson = osm2geojson(osm);
API
osm2geojson(osm, opts)
Converts OSM data (XML/JSON) to GeoJSON.
osm
: the OSM XML data in String, or OSM/Overpass JSON objectopts?
: optional - the options object, right now only supports allFeatures option, when it is set to true
, it will return a comprehensive GeoJSON object as FeatureCollection
rather than a bare Polygon/MultiPolygon
. Welcome any proposals from users.
Reminder
Please fasten your seat-belt before run the test script (node test.js)
Node.JS version
ES5/ES6 features
Dependencies
License
Written in 2018 by tibetty xihua.duan@gmail.com