0

I created a routing network based on OSM with OSM2PO in PostgreSQL with the extension pgrouting. I have got a column km (distance in km), a column cost (driving time) and max_speed. I try to create a catchment with the function pgr_drivingDistance using the column km (distance in km). This calculates a catchment with the shortest path, which is in most cases not a realistic distance for cars. Therefore I want to calculate the catchment based on the shortest driving time using cost. But in the result, I need units of meters and not time. Many thanks for any hint.

Short version: I need a catchment with distances in km for the fastest (min time) route!

Here is the standard code for pgr_drivingDistance with shortest distance in km:

SELECT *
   FROM routing_vertices_pgr
   JOIN(
SELECT * FROM pgr_drivingDistance('
SELECT id,
     source,
     target,
     km as cost
    FROM routing',
1, 100, false)) AS route ON routing_vertices_pgr.id = route.node ;
Martin
  • 39
  • 6

2 Answers2

0

If you have the feature type (highway, primary rd), creating a column with max_speed and dividing this max_speed into the distance will give you the time it takes to travel the road segment. This time can be selected as cost to give the shortest driving distance.

  • Thanks for your answer. The tool OSM2PO created already a column called `cost` with the driving time. But calculating the catchment based on `cost` won´t give me the distance in km for the fastest route. – Martin Dec 07 '16 at 19:22
  • change the cost to the column (distance/speed) to get the fastest route 1. divide the cost column by a new max_speed column where you insert the maximum speed for each feature type. 2. take this new column as the cost and calculate pgr_drivingDistance from (time as cost). – Columbo25 Dec 08 '16 at 13:02
  • Thanks for your reply. Maybe I don´t get the point, but in my opinion, it´s not possible for my purpose, because I don´t calculate any fastest route at the beginning, I can only use the function _pgr_drivingDistance_. I need the fastest routes for all nodes within a distance of 100km from a point A with information about the distance in km. – Martin Dec 19 '16 at 19:37
0

You can't do such thing... In driving distance you're deciding what is your cost (time or distance or sth else) and function is processing this cost. Cost is only one... I think one of resolutions could be to count for distance, but exclude from edges this 'not realistic for cars' using clazz or flags field. You'll find descriptions of this fields in your osm2po config file.

Jendrusk
  • 743
  • 3
  • 9