genthalili / searoute-py

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

Incorrect Route #23

Closed PravinRautNatpower closed 10 months ago

PravinRautNatpower commented 10 months ago

Origination Port of Los Angeles, USA Latitude: 33.7365 Longitude: -118.2622

Destination Port of Singapore, Singapore Latitude: 1.2644 Longitude: 103.8223

route = sr.searoute(origin, destination, units="naut",append_orig_dest=True,include_ports=True,restrictions=['northwest'])

> Returns a GeoJSON LineString Feature

show route distance with unit

print(route) {"geometry": {"coordinates": [[33.7365, -118.2622], [25.606384, -33.926564], [30, -50], [25.110338, -45.404267], [24.7149, -45.0326], [20, -40], [18, -35], [12.499733, -28.1252], [10.425227, -25.53227], [7.89386, -22.368307], [5.653262, -19.567777], [3.542734, -16.929822], [1.7833, -14.7307], [0.000405, -12.501846], [-1.087497, -11.141825], [-1.100476, -11.1256], [-1.989182, -10.0146], [-5.531121, -5.586708], [-10, -2e-05], [-13.4277, 5.5302], [-17, 11], [-18, 15], [-18, 21], [-18.76187, 24.560373], [-18.9639, 25.5045], [-19.309905, 27.00577], [-19.593968, 28.23828], [-20, 30], [-20.001431, 33.408088], [-20.001526, 33.634878], [-20.002054, 34.891316], [-20.002093, 34.985342], [-20.0021, 35.002], [-20.002089, 35.027846], [-20.001544, 36.324949], [-20.000978, 37.672504], [-20.000931, 37.783204], [-20.000334, 39.204827], [-20, 40], [-20.002182, 43.637435], [-20.002183, 43.639943], [-20.003, 45.0022], [-20.001632, 47.280732], [-20.001626, 47.291907], [-20.000174, 49.709697], [-20, 50], [-20.000464, 50.539776], [-20.000808, 50.940109], [-20.00188, 52.186447], [-20.0043, 55.0021], [-20.002982, 56.53398], [-20.002106, 57.552768], [-20, 60], [-16.015291, 62.687825], [-15, 64], [-13, 65], [-13, 66.5], [-8.6875, 70.7581], [14.528401, 68.241479], [1.2644, 103.8223]], "type": "LineString"}, "properties": {"duration_hours": 700.2589377973309, "length": 16806.21450713594, "port_dest": {"cty": "Norway", "name": "Svolvaer", "port": "NOSVJ", "t": null, "x": 14.528401, "y": 68.241479}, "port_origin": {"cty": "South_africa", "name": "Port Elizabeth", "port": "ZAPLZ", "t": 1.0, "x": 25.606384, "y": -33.926564}, "units": "naut"}, "type": "Feature"}

Not sure how it calculated South_africa and norway

genthalili commented 10 months ago

Hi @PravinRautNatpower ,

I think the reason is as searoute requires origin and destination to be a tuple of lon,lat, you might have provided it the way around.

Try it like this :

origin = [-118.2622,33.7365 ] # Los Angeles as lon,lat
destination = [103.8223, 1.2644] # Singapore as lon,lat
genthalili commented 10 months ago

Answered