Sea distances in Excel
Type two ports and a date. The row fills itself: the distance, the route container ships were taking that month, the distance by Suez and by the Cape of Good Hope, and CO₂e for the weight.
Make your link (free account)There are three ways, easiest first. All of them use one link that you make once, signed in. The link can only answer distances, routes and CO₂e. It is not an API key, and you can turn it off.
1. The workbook, with no code
- Sign in and open Freight Carbon. Go to “In your own spreadsheet” and choose “Make the link”.
- Choose “Download the workbook” and open it in Excel. If a yellow bar appears, choose Enable Content.
- Type From, To, the sailing date and the cargo in tonnes. Copy the row down for more.
| From | To | By Suez, nm | By the Cape, nm | The Cape adds |
|---|---|---|---|---|
| Shanghai | Rotterdam | 10,623 | 14,085 | 33% |
| Singapore | Rotterdam | 8,452 | 11,919 | 41% |
| Nhava Sheva | London Gateway | 6,356 | 10,797 | 70% |
| Ho Chi Minh City | Felixstowe | 8,988 | 12,454 | 39% |
Container ships mostly went by the Cape from January 2024 until the autumn of 2026. A distance read off the shortest route understates those years, so the workbook chooses by the month of sailing.
2. One formula in your own sheet
With the port of loading in A2, the port of discharge in B2 and the sailing date in C2. Replace YOUR-LINK with yours; the page where you made it writes the formula for you. It gives text, so a mistake is said in the cell; put it in VALUE() to add it up.
=WEBSERVICE("https://arcnautical.com/sheet/YOUR-LINK/nm?from="&ENCODEURL(A2)&"&to="&ENCODEURL(B2)&"&date="&INT(C2))
Instead of nm | You get |
|---|---|
km | Kilometres, by the way ships were going that month |
route | Suez, Cape or Direct |
suez_nm, cape_nm | Nautical miles by either way, where a lane has the choice |
uk_kg, eu_kg | kg CO₂e for a container ship, by the UK government average or by EU verified ship records. Add &t=20 for 20 tonnes |
row | All of it at once, as XML for FILTERXML. The workbook asks this way, once a row |
Add &via=Colombo for a transshipment port. WEBSERVICE and ENCODEURL are in Excel for Windows, 2013 and later.
3. A macro, if you want one
For Windows. In Excel press Alt+F11, choose Insert, Module, and paste this. Then in a cell: =SEADISTANCE("YOUR-LINK","nm",A2,B2,C2).
Function SeaDistance(yourLink, what, fromPort, toPort, sailing)
Dim http, url, answer
url = "https://arcnautical.com/sheet/" & yourLink & "/" & what _
& "?from=" & Application.WorksheetFunction.EncodeURL(fromPort & "") _
& "&to=" & Application.WorksheetFunction.EncodeURL(toPort & "")
If IsDate(sailing) Then url = url & "&date=" & CLng(CDate(sailing))
url = url & "&wait=20"
Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
http.SetTimeouts 5000, 5000, 5000, 30000
http.Open "GET", url, False
http.Send
answer = http.ResponseText
If http.Status = 200 And IsNumeric(answer) Then
SeaDistance = CDbl(answer)
Else
SeaDistance = answer
End If
End Function
The link is in the workbook, so anyone you send it to can ask for distances with it. Do not put an API key in a workbook: a key opens your whole account.
From a program
Use an API key and POST /api/v1/voyage-assessments. Ports are UN/LOCODEs: resolve a name first with GET /api/v1/ports?query=rotterdam, which needs no key.
curl -X POST https://arcnautical.com/api/v1/voyage-assessments \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: lane-INNSA-NLRTM-001" \
-H "Content-Type: application/json" \
-d '{"route":{"origin":"INNSA","destination":"NLRTM"},"include_geometry":false}'
The distance is route.distance_nm. Where a lane can go either way round Africa, alternatives carries the other one. An assessment is also a risk score and is counted against the key’s allowance; a distance on its own is better asked through the link above. Full contract: API docs.
What the distance is
- The shortest navigable sea route between the two ports, kept off land and out of passages ships cannot use. It is not a great circle and not a tariff distance.
- Where a lane can go by Suez or by the Cape, the way most container traffic was going in that month (IMF PortWatch). Ask for
suez_nmorcape_nmto decide yourself. - A port that cannot be told is answered in words, with the ports it looks like. Nothing is guessed.
- CO₂e: DESNZ/DEFRA container ship average, fuel made and burned; or the average of EU MRV verified reports with 15% added for the distance ships really sail.
- One link answers 5,000 times a day and works out 200 lanes a day that nobody has asked before. A lane already worked out answers at once. A new one takes a few seconds: the cell says it is being worked out, and Ctrl+Alt+F9 asks again.
A whole shipment list at once, with the sources for an auditor: upload it in Freight Carbon.