Home

Awesome

osmtogeojson

Converts OSM data to GeoJSON. Try the demo!

This code is used in and maintained by the overpass turbo project.

Build Status

Usage

command line tool

Installation:

  $ npm install -g osmtogeojson

Usage:

$ osmtogeojson file.osm > file.geojson

Supported command line options are shown with:

$ osmtogeojson --help

When working with extra large data files (≳ 100 MB) it is recommended to run the programm with a little extra memory to avoid process out of memory errors. The easiest way to do this is by running the command as node <path-to-osmtogeojson> and setting the --max_old_space_size=… parameter to the available memory size in MB (osmtogeojson typically needs about 4-5 times the input data size). On a Unix system, you can use the following command:

$ node --max_old_space_size=8192 `which osmtogeojson` large.osm > large.geojson

nodejs library

Installation:

$ npm install osmtogeojson

Usage:

var osmtogeojson = require('osmtogeojson');
osmtogeojson(osm_data);

browser library

<script src='osmtogeojson.js'></script>

osmtogeojson(osm_data);

API

osmtogeojson( data, options )

Converts OSM data into GeoJSON.

The result is a javascript object of GeoJSON data:

GeoJSON

The GeoJSON produced by this library will include exactly one GeoJSON-feature for each of the following OSM objects (that is everything that is also visible in overpass turbo's map view):

All data is given as a FeatureCollection. Each Feature in the collection has an id property that is formed from the type and id of the original OSM object (e.g. node/123) and has the member properties containing the following data:

If the option flatProperties is set to true, the properties object will not contain any nested object literals, but directly provide a concise id, meta data and the tags of the respective OSM object.