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.

2 Answers 2

  • 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 - http://www.opencyclemap.org/?zoom=5&lat=39.98469&lon=-99.18887&layers=B00 which shows the routes/ways colour coordinated.

source http://wiki.openstreetmap.org/wiki/Osm2pgsql/schema#Tables_Created

  • 1
    Note that osm2pgsql’s --slim mode also creates tables planet_osm_nodes, planet_osm_ways and planet_osm_rels. IIUC these table are used by osm2pgsql internally (e.g. for updates) but are not of interest for the user. Commented Jun 16, 2020 at 11:06
  • Is there a possibility to get the planet_osm_waystable without using the --slim option? Commented Apr 2 at 8:11

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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