I am seeking an algorithm, not GIS software.

To find the shortest path between two points at sea with land between them, you can consider land as a polygon shaped obstacle between these. The concept of finding the shortest path avoiding obstacles is outlined here: http://alienryderflex.com/shortest_path/

Is there a publicly available algorithm to find the shortest path between two points at sea, but going along the coast and not across land?

I am working with thousands of points, so it has to be an algorithm, not a workaround using GUI software.

Creating optimised path between nodes avoiding polygons entities using QGIS asks and gets help to do this in QGIS, but it currently has only one answer and that is not applicable for this problem. To do this manually, as proposed in the answer in that question is not an answer to my problem as that solution is unfeasible with high amount of data. I am asking for an algorithm, not a method to do it in QGIS.

  • 1
    Thanks for reposting your question as it saved me finding your other one, reopening it and closing it as a duplicate
    – Ian Turton
    Commented Nov 15, 2022 at 19:47
  • 2
    @IanTurton Your "duplicate" solves this is qgis, this specifically asks for an algorithmical implementation in Python or in Postgis.
    – bjornasm
    Commented Nov 15, 2022 at 19:50
  • 3
    @IanTurton I agree and think it's a valid question.
    – Shawn
    Commented Nov 15, 2022 at 21:34
  • 2
    @bjornasm the searoute python package will probably work for you. github.com/genthalili/searoute-py
    – Shawn
    Commented Nov 16, 2022 at 1:39
  • 1
    how about gis.stackexchange.com/questions/158972/… then
    – Ian Turton
    Commented Nov 16, 2022 at 13:09

1 Answer 1


I would expect any maze solving algorithm to be applicable to finding a route across a raster representing oceans with ports around the edges.

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.