Osm2pgsql style file question

Indeed this a challenge at OSM, as this tagging schema develops step by step. For example before there were aerial imagery available, users usually just added nodes for restaurants, as there were no building outlines available. But in present a lot of people to 'armchair mapping' and so we get more and more buildings, and you might need to consider watching for (closed) ways that are tagged as amenity=restaurant.

Usually you lookup this lists to get the right OSM tags:

  • http://wiki.openstreetmap.org/Map_Features
  • http://wiki.openstreetmap.org/wiki/How_to_map_a

At the tag pages, you usually find a box visualizing the use on nodes, ways, relation elements. But you can also browse http://taginfo.openstreetmap.org directly.
Please keep in mind that there can be different tagging schemas (usually allowing different level of details) and that there can be local differences etc. The wiki is just a suggestion, similar to the editor presets, but OSM is open that people contribute in their own way.

Then you just need to decide on your usecase, with which level of detail osm2pgsql should import this geometry to your DB http://wiki.openstreetmap.org/wiki/Osm2pgsql#Import_style


The current osm2pgsql default.style explains in much more detail the meaning of the various flags and OsmTypes. If you're looking at writing your own style file, you should start with the empty.style example.

Quoting what I wrote at the time, the five flags are

  • polygon - Create a column for this tag, and objects the tag with are areas
  • linear - Create a column for this tag
  • phstore - Don't create a column for this tag, but objects with the tag are areas
  • delete - Drop this tag completely and don't create a column for it. This also prevents the tag from being added to hstore columns
  • nocache - Deprecated and does nothing

The two most important are polygon and linear. As the OSM data model does not by itself distinguish between linear features and areas, these flags determine if an object is added to the planet_osm_polygon or planet_osm_line table as a POLYGON or LINESTRING respectively.