[OSM-dev] OGR driver for OSM data

Jochen Topf jochen at remote.org
Thu Mar 8 22:10:40 GMT 2012


On Thu, Mar 08, 2012 at 03:40:53PM -0500, Josh Doe wrote:
> On Thu, Mar 8, 2012 at 2:02 PM, Jochen Topf <jochen at remote.org> wrote:
> > This idea comes up again and again. Writing a generic OGR driver for OSM data
> > would be very difficult, because the data models just don't match. You'd have
> > to have some kind of complex mapping between the two worlds. Thats why nobody
> > has done it.
> 
> There's certainly not a direct mapping, but I don't see why we can't
> handle most common cases.
> Point -> Node
> Way (without area=yes or certain other tags, e.g. leisure=pitch) -> LineString
> Way (with area=yes or certain other tags, e.g. leisure=pitch) -> Polygon
> Relation (type=multipolygon, with one inner/outer ring) -> Polygon
> Relation (type=multipolygon, with more than one one inner/outer ring)
> -> MultiPolygon

The problem is not so much the geometries. Its the open tagging scheme which
doesn't fit the fixed attribute names/types of the traditional GIS world.
As a simple example, you might want to map "oneway=yes" and "oneway=true" and
other versions to a simple boolean field. Real life examples are much more
complex. OSM data basically always needs this cleanup and canonicalization
and mapping step.

> I don't even care about implementing writing functionality. My
> interest is letting non-OSM GIS users easily use OSM data, not for
> them to produce OSM data (those in the OSM community can use Osmium,
> ogr2osm, etc. for that). The most annoying part is maintaining a list
> of tags that generally (in the absence of area=no) indicate a way is
> an area.

Osmium doesn't do OGR -> OSM, it does OSM -> OGR, just as you want. You'll
"just" have to do some programming, because I (as the library author) don't
know what you want your mapping to look like. (btw if you are happy with
just Shapefile output, not full OGR, you can use the osmjs program supplied
with Osmium and write the mapping in Javascript, which is easier than C++
obviously. Someday I will extend Osmium to allow full OGR access from
Javscript.)

Jochen
-- 
Jochen Topf  jochen at remote.org  http://www.remote.org/jochen/  +49-721-388298




More information about the dev mailing list