OSMLib on Ubuntu
This page describes using OSMLib on ubuntu. OSMLib is a ruby library for working with OSM data. The main functionality it provides is conversion to various formats including Shapefiles
Installation on Ubuntu
To OSMLib working on ubuntu, you will need to install the Ruby Developer Version and some other Libraries listed below. An essential part of the Ruby core (mkmf.rb, listet in the Ruby Standard Library is missing in the default installation of Ruby 1.8 on Ubuntu 7.04, because the full methods and classes of ruby are only available in the developer packages. Therefore its necessary to install these packages first from the universal repositories (have a look at your /etc/apt/sources.list) to get the libxml-ruby library run correctly. Its important for XML-Parsing the OSM Data. The required commands are:
sudo apt-get install ruby1.8-dev sudo apt-get install libxml2-dev
Additionally we need rubygems, which is the package management system under ruby like adept under Ubuntu. So install it with
sudo apt-get install rubygems
if not already done. Its important to use the gem manager (command: 'gem install') because there's no guarantee that everything works properly when you use the apt manager to install the last hinging libraries libxml-ruby, GeoRuby (for Spatial Support), builder (for KML-Export) and osmlib-base (for basic OSM-data model support).
sudo gem install libxml-ruby sudo gem install GeoRuby sudo gem install builder sudo gem install osmlib-base
Finally we can install and use the OSMLib
sudo gem install osmlib-export
There is an executable File called 'osmexport' in /var/lib/gems/1.8/bin, which control the conversion process and this File should be globally referenced in PATH of Ubuntu to allow the access at any directory. To do this just add
PATH=${PATH}:/var/lib/gems/1.8/bin
export PATH
to the end of File ~/.bashrc, while ~ allocates to your home directory and .bashrc is hidden.
See also
- OSMLib - For further information on OSMLib
- Shapefiles - For alternative approaches to creating of shapefiles