There are online APIs available to calculate Port to Port distances, but I would like to do it at free of cost. I have tried things mentioned in other similar questions Find path by sea from coastal point A to coastal point B but it did not serve my purpose.
Reason :
- The distance calculated from left extreme of the map to right extreme of the map is not right as the earth is spherical. Example : Distance between -150,50 to 100,50 is less if it is calculated in spherical dimensions.
- The result gives only the route 'path', but unable to calculate the distance in km or miles from the path variable.
I have tried distance calculation like haversine, etc but those do not take only water routes as a consideration. The ultimate aim is to calculate port to port distance the vessel needs to travel via marine route. Not need to be very accurate like ocean beds, depth, etc need not be taken into consideration. Just the shortest distance via ocean from Port A to Port B in km or Nm is enough.
Inputs:
Start Destination :
[lat,long] End Destination :
[lat,long]
Output Expected:
Route coordinates:
[lat1,long1
lat2,long2
lat3,long3
lat4,long4
lat5,long5 ]
Distance:
xxx kms