genthalili / searoute-py

A python package to calculate the shortest sea route between two points on Earth.
Apache License 2.0
63 stars 14 forks source link

GB to NZ #27

Closed jimrobo closed 4 months ago

jimrobo commented 4 months ago

This is an odd one!

GB to new zealand tehcnicallyis 39 days going east and 41 days going west.

The library wants to route it east naturally because thats the shortest route.

Any suggestions to potentially weight it so it sends it west? there are far too many data points for me to add an exclusion zone down here quickly. I was wondering if there is an easier way??

image

it should realistically go this way but I understand why it doesnt. It would make my life easier if I could somehow push it in this direction though!

image
genthalili commented 4 months ago

Hi @jimrobo, I think the reason is because of missing passage for the South America, more specially the strait in south of Chili. I will update this in the future release to include these passages close to South Africa as well.

Here is a quick fix before the next release :

import sraroute as sr
# chili passages
passage_chili = [[(-80, -60), (-70, -60.0001)],
 [(-70, -60.0001), (-80, -60)],
 [(-68, -52.4), (-70.45, -52.7501)],
 [(-70.45, -52.7501), (-68, -52.4)],
 [(-71.385, -55.3608), (-68.2442, -55.8267)],
 [(-68.2442, -55.8267), (-71.385, -55.3608)]]

for i in passage_chili:
    u,v = i
    sr.M[u][v]['passage'] = 'chili'

# make sure to add 'chili' in the restrictions together with panama and northwest
sr.searoute((9.4664416,49.8470651), (171.4890674,-43.2393364), restrictions=['panama', 'northwest', 'chili'])
jimrobo commented 4 months ago

Brilliant! Also gives me a framework if I want to manually tinker with some of the zones going forward rather than looking through the source data.

Really is an excellent library!