I have a question about the style files used for osm2pgsql.

These files have a structure as follows:

# OsmType  Tag          DataType     Flags
node,way   access       text         linear
node,way   addr:housename      text  linear
node,way   addr:housenumber    text  linear
node,way   addr:interpolation  text  linear
node,way   admin_level  text         linear
node,way   aerialway    text         linear
node,way   aeroway      text         polygon
node,way   amenity      text         polygon

My question is this, how do I know if I should use polygon, linear, hstore, etc.. for the Flags values? The style file gives a brief explanation, but I am looking for further information.


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.


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:

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

  • Very helpful, thank you, can you also dive into the Flag tag of linear vs polygon? – code base 5000 Jan 30 '14 at 15:21
  • I don't have experience on creating this kind of styles, so you might want to ask for more details at help.osm.org – Mapper Feb 3 '14 at 11:03
  • +1 for http://taginfo.openstreetmap.org very useful. A Tag a la carte will be greate. We choose tags and download a style file at the end. – Magno C Jun 8 '16 at 11:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.