I am working for a project. I have a road network which has been imported in PostgreSQL/PostGIS database. I can query shortest path between two points. I want to get route plan with certain distance. Suppose, I want to go from point A to point B. There may have different way to go from point A to B. But, I want to fix the length, suppose, 10 km. That means, I want to know the route plan to go from point A to point B but in 10 km range. Is it possible to get this kind of query using pgRouting? Or I should use any other tools? If it is possible how should I write the query?

Note: in my database table 'route', i have 'gid', 'source', 'target', 'cost' etc columns.

Thanks, in advance.

1 Answer 1


No, I don't think pgRouting can do this. Shortest path algorithms minimize costs. If you want a fix length there would be too many possibilities.

K-shortest path is an algorithm that returns alternative routes (someone is currently working on an implementation as far as I know). But this still wouldn't allow you define the length.

  • I agree, and there may not even be any routes at exactly 10 km length. Commented Apr 5, 2012 at 6:14

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.