Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
License-MIT release under MIT license Jul 8, 2013
package.json adding bugs and license to package. Jul 21, 2013


Node-mongosm is a stepping stone. It bridges the gap from raw .osm file xml to MongoDB via a simple commandline interface.


Install the latest stable build from npm. This will install the mongosm executable to your path for easy command line use.

npm install mongosm

Optionally you can install the latest from this repo by cloning and installing with the -d option.

npm install -d


With the standard installation of Mongodb you can start parsing from the command line

mongod &
mongosm -v -f "your-file.osm"

Alternatively in lib/options.js set the {filename: "your_file.osm"} and run the app. You will also want to set {upsert: true/false} to your needs.

note: if upsert = false, documents which already exist in the database will not be modified and will not be printed out in verbose mode.

node mongosm

All Mongoose options are passed to mongoose connection, from the options.mongoose object. Uploading to an external database can be achieved by adding any settings to the mongoose: {} object in options.js

##Command-line Flags

  -v verbose
  -l to lowercase
  -f file path
  -s suppress errors
  -upsert upcert all entries : defaults to save
  -tb use timebucketing for osm timestamp and update timestamp
  -sc places all nodes, ways and relations in the 'geo' collection
  -k removes all attributes except ones supplied in comma separated list EX: -k way:user,timestamp
  -i includes all attributes except ones supplied in comma separated list EX: -i way:user,timestamp
  -host host name
  -db database
  -u username
  -p password
  -port port
  -h help


Command line options are generally preferred, but option defaults may be manually set in the options.js file.

Document Filter Options:

  ignoreAttributes: []  // items to excluded
  keepAttributes: [] // strict list of items to include

only one document filter type should be needed

Way Specific Options:

  geometry: true // include the generated LineString or Polygon
  nodes: false // include the array of node references that make up the way

Database Options:

All Mongoose options are supported from options.mongoose in options.js.

##Document Filtering

By setting the options ignoreAttributes, keepAttributes per node, way or relation you can filter the document pre save. The options should be provided an array of the key names which are to be effected. This can also be achieved by using the -k or -i command line flag in the following format :,.

Via Command Line:

./mongosm -v -k way:loc,user

Via Options:

way {
  keepAttributes: ['loc','user']

##Time Stamp Bucketing

When run with the timeBucket option to true or the -tb flag. You can search and index via day month or year much more efficiently with an $exists operator.

Searches for all entries in january of 2009 would look like.



Instead of downloading and storing the latest .osm file you can directly pipe data from the OSM API.

curl "" | ./mongosm -upsert


  • Testing vs sample .osm files
  • Support for multiple files
You can’t perform that action at this time.