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

We are currently working with pgRouting and found that there's no way of implementing turn restrictions (e.g. banned right or left turns). While it is possible to assign "to_cost" and "rule" in Shooting * algorithm... I couldn't find a way of implementing these restrictions using A star and Dijktra algorithms.

Is there a way of implementing special turn restrictions in A star and Dijkstra methods ?

share|improve this question
up vote 3 down vote accepted

Yes, we have just implemented a turn restricted shortest path (trsp). I think it has been checked into a git branch at origin/trsp. It is not documented yet. If you have questions or need help ask on the pgrouting list, because that is where I hangout.


share|improve this answer

Are you looking up this?

7.2. Restricted access¶

Another possibility is to restrict access to roads of a certain type by either setting a very high cost for road links with a certain attribute or by not selecting certain road links at all:

UPDATE classes SET cost=100000 WHERE name LIKE 'motorway%';

Through subqueries you can “mix” your costs as you like and this will change the results of your routing request immediately. Cost changes will affect the next shortest path search, and there is no need to rebuild your network.

Of course certain road classes can be excluded in the WHERE clause of the query as well, for example exclude “living_street” class:

SELECT * FROM shortest_path_shooting_star(
        'SELECT gid as id, class_id, source, target, length*c.cost as cost,
                x1, y1, x2, y2, rule, to_cost, reverse_cost*c.cost as reverse_cost
        FROM ways w, classes c
        WHERE AND class_id != 111', 6585, 8247, true, true);

Of course pgRouting allows you all kind of SQL that is possible with PostgreSQL/PostGIS.

It's a fragment from workshop.

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.