0
  1. I downloaded the .osm map data, and I imported it to postgresql using the m2pgrouting.
  2. I have a CSV file on violence data, with three attributes, nature of occurrence, latitude and longitude.

How do I plan a route avoiding these points of violence?

What should I do, can I cross the data with street network?

Does pgrouting topology allow this?

If not, which approach should I follow?

  • Yes, you can either make the cost really high for the segments in question or you could explicitly exlude nodes/links from the query that is passed to many pg_routing function, see this link – John Powell Nov 18 '18 at 11:33
  • I tried to do this but I do not know how to use the points of violence that are in the CSV file. – Sting Silva Nov 18 '18 at 17:48
  • Load them and snap them to the nearest road segment or road node. – John Powell Nov 19 '18 at 13:32
0

I can explain with details. Imagine you drive from node 7593 to node 17686 in a short way through edge 395166. You can perform the following query in pgrouting

with node_edge as (SELECT node, edge  FROM 
                pgr_dijkstra('SELECT id, source, target, cost, reverse_cost FROM roads',7593,17686))
    select node_edge.node, node_edge.edge, roads.geom_way from node_edge, roads
                                    where node_edge.edge = roads_9_309_332.id

The result below First query

Then something happened on the edge 395166. You add a condition (where id<>395166) in the internal query so that the whole query will look like

 with node_edge as (SELECT node, edge  FROM 
                    pgr_dijkstra('SELECT id, source, target, cost, reverse_cost FROM roads where id<>395166',7593,17686))
        select node_edge.node, node_edge.edge, roads.geom_way from node_edge, roads
                                        where node_edge.edge = roads_9_309_332.id

After performing that query you will see that the route will bypass the dangerous road segment.

Bypass route

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.