Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using osm2pgsql to populate a North America OSM database from planet.osm.

I like how simple the resulting PostGIS schema is, but I'm a bit confused by its contents.

I have the two tables planet_osm_roads and planet_osm_line. I assumed that planet_osm_roads contained all the highway data, but then discovered that it only contains a fraction of the roads in some of the 'highway' types.

For example, planet_osm_line has over 12,000,000 lines with a 'highway' value of 'residential'. However, planet_osm_roads has only 2,000. By comparison both tables have the same number of 'motorway' features. Looking at the data I can't tell why some features would be in the one table but not the other.

I'd really like to see the rules the osm2pgsql uses to direct line features into each table.

I tried looking through the osm2pgsql source code to shed light on the mystery but so far I've not found what I'm after.

Any suggestions very welcome.

share|improve this question
up vote 4 down vote accepted
  • planet_osm_line: contains all imported ways
  • planet_osm_point: contains all imported nodes with tags
  • planet_osm_polygon: contains all imported polygons. Relations seem to be resolved for that.
  • planet_osm_roads: contains a subset of planet_osm_line suitable for rendering at low zoom levels. planet_osm_line contains too many elements to render on overview maps.

use osm_line

For a good example visit - which shows the routes/ways colour coordinated.


share|improve this answer

planet_osm_roads contains only ways that are used for rendering low zoom levels, such as motorsways, rivers, etc. It does not contain details like residential roads, streams and various other features normally rendered only at high zoom.

The default C tag transform definitions of what to add to the roads table are tagtransform.cpp

If you want to customize this, you're probably best off writing a lua tag transform. For an example, you can see style.lua, the sample lua tag transform.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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