[JT] Jochen Topf's Blog
Wed 2011-09-14 18:30

OGR support for Osmium

Osmium now includes OGR support. OGR is a popular Open Source library for converting different GIS storage formats into each other. It supports PostGIS, Shapefiles, Spatialite, and many other formats. I had started working on OGR integration many weeks ago, but didn’t quite finish it. I have now added the last bit: Support for OGR Multipolygons. This opens up a lot of new possibilities for Osmium users.

People have often wished for integration of the OSM format into the OGR library, but this is difficult because of the flexible mapping needed between the OSM format and the other GIS formats supported by OGR. Osmium does not integrate the OSM file format into the OGR library. Instead it gives you methods to create OGR geometries from OSM data. It is your job to decide which OSM objects your are interested in and convert OSM tags into attributes for OGR. These attributes plus the geometries you get from Osmium are put into OGR features and written out. While this is not as easy as just calling some command line program, it is really not that difficult either. But to use the OGR support you have to do some programming in C++. The OGR stuff is not yet exposed on the Javascript side of Osmium. To get you started two example programs are provided with Osmium: osmium_toogr and osmium_toogr2. The first creates a spatialite database with points and linestrings, the second a spatialite database with multipolygons.

Tags: dev · gis · ogr · openstreetmap · osmium