PostGIS – pgRouting Ways Table Attributes Description

openstreetmaposm2pgroutingpgroutingpostgispostgresql

I've imported an extract of OSM data for my region of interest to Postgresql using osm2pgrouting 2.3.6 in Linux, using mapconfig_for_cars.xml configuration file, and I've found that it created tables as expected:

  • ways_vertices_pgr
  • ways
  • pointsofinterest
  • configuration

Now I wish to find a description of the data fields of the ways table, specially the cost, cost_s and priority ones, and which are used for evaluation by the routing algorithms, as I need to elaborate and put my specific cost values for my application.

Best Answer

Unfortunately, the docs on osm2pgrouting are sparse at best - you will find some use cases and examples in the numerous pgRouting Workshops, with further hints and detailed explanations hidden inside the chapters (e.g. here).

As first aid, you can assume that:

  • cost and reverse_cost is given as segment length [degrees]
  • cost_s and reverse_cost_s is given as traversal time (length/maxspeed) [seconds]
  • priority is hard-coded as good measure, given as FLOAT to allow for priority ranges (i.e. a priority between 1.00 [incl.] and 2.00 [excl.] refers to all major roads [highway to tertiary], with the decimal part denoting the actual road type)

However, pgRouting does not evaluate anything by itself; rather, it allows for (and expects) custom SQL strings to be passed into its functions, that in turn will get executed as queries dynamically - and only their results will get evaluated.

The tables that are created by osm2pgrouting are best practice structures only, and aim at providing a plug&play experience - they are in no way required for the suite of functions in pgRouting to work and you can freely customize their structure.

Related Question