Last Update: Tue Jun 24 09:23:47 +0200 2008

OSM Library - SQLite

A library for importing/exporting OpenStreetMap data into/from SQLite.


This work is released into the public domain. This applies worldwide. In case this is not legally possible, any entity is granted the right to use this work for any purpose, without any conditions, unless such conditions are required by law.


Jochen Topf <>


For more information see the OSM Library home page at or the Rubyforge project page at . The OpenStreetMap web page is at .


  • libxml-ruby (for XML parsing)
  • sqlite3
  • builder (for XML generation)
  • osmlib-base

Dependencies are not all installed automatically when installing the gem packages because this breaks when the packages are already installed as Debian packages.

SQL Schema

See files/doc/sql-schema.html für details of the used SQL schema.

Executable Usage

An executable ‘osmsqlite’ using this library is included in the bin directory. If you have installed the osmlib-sqlite gem package you should have it in your path. If you use the Debian rubygems package it will have been installed in /var/lib/gems/1.8/bin or similar, you‘ll have to adjust your path or add a symlink from /usr/local/bin or so.

You can import an OSM XML file into a SQLite database with this call:

  osmsqlite import OSMFILE.osm OSMDB.db

And export it again:

  osmsqlite export OSMDB.db OSMFILE.osm

To only export marked data use:

  osmsqlite export -m OSMDB.db OSMFILE.osm

See the SQL schema for more information about marking data. There is currently no way to do this comfortably from the command line, you‘ll have to call

  sqlite3 OSMDB.db

to go into the database manually and mark the parts you need.

Call ‘osmsqlite help’ for more information.

Library Usage

See OSM::SQLite::Database.