How Long Does It Take A Ship To Sail Around The Globe?

metadata

On the 23rd of March 2021 a container ship ran aground in the Suez Canal. It was freed on the 29th of March 2021 and it was eventually released by the Egyptian government on the 7th of July 2021, after which, it proceeded on its journey. The whole saga caused massive disruption to global shipping as it forced container ships to divert around Africa instead of sailing through the Suez Canal. At the time, various numbers were floated about how much longer it takes to sail around Africa rather than through the Suez Canal. These numbers always seemed over-simplified to me as they never caveated themselves enough about the exact source and destination of shipping routes: the exact benefit of the Suez Canal depends on where you are going and where you have come from.

I decided to create some software to calculate the sailing times from any point in the world: GST (Global Sailing Times). This blog post describes how it works, some of the pitfalls of calculating something so complicated so generically and then reports some results of sailing around the world from Portsmouth. This project has only been made possible by my recent blog post on reliably buffering a shape (in fact, it was creating this project which forced me to improve my functions so that they are reliable).

§1 Basic Method

The method employed by GST is conceptually very simple:

  1. define the ship’s starting Point;
  2. buffer the ship’s starting Point by a Geodetic distance (thus creating a Polygon);
  3. subtract any land which overlaps with the ship’s Polygon; then
  4. keep on buffering/subtracting the ship’s Polygon until it has grown to cover all sailable sea(s).

The only extra step required is that the Polygons which describe the land cannot have any narrow headlands/spits which are narrower than the buffering distance, otherwise the ship will jump over them rather than sailing around them. Therefore, the land itself needs buffering initially too. In effect, this is simply saying that the ship cannot sail too close to shorelines.

You can imagine that whilst this method is very simple, providing that you can reliably buffer a Point/Polygon, it could have lots of choices involved about how large the steps are, how detailed the land is, etc … which can strongly affect calculation time.

§2 Shoreline Dataset

For this project I chose to use the GSHHG (Global Self-Consistent Hierarchical High-Resolution Geography) shorelines dataset, which instantly opened up a choice to the user: what resolution should be used? Within the GSHHG shorelines dataset there are five resolutions to choose from:

The animation below shows what the shorelines around Portsmouth look like for these five different resolutions. The “c” resolution is really quite crude - the Isle Of Wight is little more than a line!

Download:
  1. 512 px × 341 px (0.2 Mpx; 39.8 KiB)
  2. 1,024 px × 683 px (0.7 Mpx; 98.2 KiB)
  3. 2,048 px × 1,365 px (2.8 Mpx; 239.9 KiB)
  4. 2,700 px × 1,800 px (4.9 Mpx; 314.5 KiB)

Within the GSHHG shorelines dataset there are six levels to choose from too:

Upon first consideration, you may think that the boundaries that are needed are between land and ocean (1) and between Antarctica ice and ocean (5). However, at the full resolution there is a bug in the shoreline of Antarctica which cannot be easily fixed. Therefore, I also include the boundary between Antarctica grounding-line and ocean (6) and merge all three levels together (rather than just merging level 1 and level 5 together). This is demonstrated in the animation below: red boundaries are level 1; green boundaries are level 5; blue boundaries are level 6; and cyan boundaries are the union of levels 5 and 6. Note how a huge chunk of land is cut out of Antarctica in the green boundary when displaying the full resolution in the upper-right subplot.

Download:
  1. 512 px × 512 px (0.3 Mpx; 366.1 KiB)
  2. 1,024 px × 1,024 px (1.0 Mpx; 1,013.7 KiB)
  3. 2,048 px × 2,048 px (4.2 Mpx; 2.8 MiB)
  4. 3,600 px × 3,600 px (13.0 Mpx; 5.5 MiB)

Finally, the aforementioned trick of buffering the land to avoid the ship jumping over narrow spits of land has the detrimental effect of closing off some narrow passages. The below animation shows a selection of narrow passages around the world for a variety of GSHHG shorelines dataset resolutions and pyguymer3.geo.buffer() settings. The “Rivers and Lake Centerlines” Natural Earth dataset is used to ensure that the Panama Canal and Suez Canal are always kept open; other passages (such as The Dardanelles in the lower-left subplot) are at the mercy of the user.

Download:
  1. 512 px × 512 px (0.3 Mpx; 325.9 KiB)
  2. 1,024 px × 1,024 px (1.0 Mpx; 988.9 KiB)
  3. 2,048 px × 2,048 px (4.2 Mpx; 2.7 MiB)
  4. 3,600 px × 3,600 px (13.0 Mpx; 5.4 MiB)

Some narrow passages are closed off by the buffering, particularly at higher resolutions when more tiny islands are included in the GSHHG shorelines dataset. Some of these will affect the routes that the ship can sail around the world - others just make certain ports inaccessible (such as Istanbul in the lower-centre subplot).

After all of the processing to obtain a useable dataset of the coastlines, an important consideration is how many points are used to describe the coastlines. Some places in the world will have more points to describe their coastlines than others. This can significantly affect run time later on. For different levels of processing quality, here are maps of the number of points in the coastline dataset around the world.

Download:
  1. 512 px × 256 px (0.1 Mpx; 76.6 KiB)
  2. 1,024 px × 512 px (0.5 Mpx; 192.6 KiB)
  3. 2,048 px × 1,024 px (2.1 Mpx; 475.8 KiB)
  4. 3,600 px × 1,800 px (6.5 Mpx; 101.8 KiB)
Download:
  1. 512 px × 256 px (0.1 Mpx; 77.5 KiB)
  2. 1,024 px × 512 px (0.5 Mpx; 192.4 KiB)
  3. 2,048 px × 1,024 px (2.1 Mpx; 472.4 KiB)
  4. 3,600 px × 1,800 px (6.5 Mpx; 104.2 KiB)
Download:
  1. 512 px × 256 px (0.1 Mpx; 76.7 KiB)
  2. 1,024 px × 512 px (0.5 Mpx; 186.7 KiB)
  3. 2,048 px × 1,024 px (2.1 Mpx; 457.2 KiB)
  4. 3,600 px × 1,800 px (6.5 Mpx; 106.4 KiB)

At the highest fidelity settings, the region near the Western coast of North Korea has the highest concentration of points, which was unexpected.

§3 Angular Convergence

When pyguymer3.geo.buffer() is called, there is an argument called nang, which is the number of angles around a point to populate when buffering a point. The higher the number the smoother the exterior of the Polygon is, however, computational time and memory usage will go up. Furthermore, owing to the loop in the basic method outlined above, the value of nang determines how many starting points there are on the next iteration, so nang exponentially affects computational time and memory usage when sailing a ship. The map below shows how nang affects ships sailing out of Portsmouth.

Download:
  1. 384 px × 512 px (0.2 Mpx; 116.5 KiB)
  2. 768 px × 1,024 px (0.8 Mpx; 316.3 KiB)
  3. 1,536 px × 2,048 px (3.1 Mpx; 949.8 KiB)
  4. 2,700 px × 3,600 px (9.7 Mpx; 1.2 MiB)

Unsurprisingly, the biggest difference between the different values of nang is how well the ship sails around corners. This is particularly obvious at the very Western tip of The Isle Of Wight. The user must make a trade between run time and quality of the final answer.

The lower plot shows how the Euclidean area of the Polygons converges as a function of nang. A value of 33 is within 1% of the “correct” answer, and will be used as the “best” value later on.

§4 Radial Convergence

When performing the loop in the basic method outlined above, the user can choose the step size, i.e., how far to sail the ship in a single iteration before calculating the next iteration. The smaller the distance the smaller the buffering of the land (and hence the less likely it is that narrow passages will be closed off), however, computational time will go up. Furthermore, owing to the loop in the basic method outlined above, the step size linearly affects computational time when sailing a ship. The map below shows how the step size affects ships sailing out of Portsmouth.

Download:
  1. 384 px × 512 px (0.2 Mpx; 107.3 KiB)
  2. 768 px × 1,024 px (0.8 Mpx; 281.1 KiB)
  3. 1,536 px × 2,048 px (3.1 Mpx; 828.8 KiB)
  4. 2,700 px × 3,600 px (9.7 Mpx; 959.3 KiB)

Unsurprisingly, the biggest difference between the different step sizes is how well the ship sails between land. This is particularly obvious along the Northern coast of The Isle Of Wight. The user must make a trade between run time and quality of the final answer.

The lower plot shows how the Euclidean area of the Polygons converges as a function of step size. This plot is more nuanced than the earlier one: here, comparing each Polygon is unfair as they are each seeing differently buffered land. (Additionally, buffering by 625 metres is not enough to join The Isle Of Wight to the mainland, therefore, the lines for “60km”, “70km” and “80km” have a different convergence/shape to the others as GST has deleted the interior void of The Isle Of Wight once it became completely encompassed by the ship.) When picking a step size it is perhaps better to make your decision on how it affects the narrow passages that you are interested in rather than the Euclidean area of the Polygons. A value of 1.25 kilometres will be used as the “best” value later on.

§5 Conservatism

GST also has a conservatism argument, which is a fudge factor for how much more resolution should be applied to ensure that the final answer looks good. This section will use the example of sailing out from Portsmouth at 20 knots for 6 days and seeing where the ship ends up.

The below plot compares four different metrics of the final Polygon for a series of different runs of GST. Here: nang is the number of angles (as described above); prec is the step size (as described above) in metres; and cons is the conservatism (a value of 1.0 is no conservatism). After the plot, there are a series of videos comparing the different runs of GST further.

Download:
  1. 512 px × 384 px (0.2 Mpx; 43.5 KiB)
  2. 1,024 px × 768 px (0.8 Mpx; 110.2 KiB)
  3. 2,048 px × 1,536 px (3.1 Mpx; 279.3 KiB)
  4. 2,880 px × 2,160 px (6.2 Mpx; 222.0 KiB)

The below video compares:

Download:
  1. 512 px × 284 px (0.1 Mpx; 396.5 KiB)
  2. 1,024 px × 568 px (0.6 Mpx; 939.1 KiB)
  3. 2,048 px × 1,136 px (2.3 Mpx; 1.7 MiB)
  4. 2,700 px × 1,500 px (4.0 Mpx; 2.5 MiB)

The below video compares:

Download:
  1. 512 px × 284 px (0.1 Mpx; 395.2 KiB)
  2. 1,024 px × 568 px (0.6 Mpx; 939.8 KiB)
  3. 2,048 px × 1,136 px (2.3 Mpx; 1.7 MiB)
  4. 2,700 px × 1,500 px (4.0 Mpx; 2.6 MiB)

The below video compares:

Download:
  1. 512 px × 284 px (0.1 Mpx; 284.4 KiB)
  2. 1,024 px × 568 px (0.6 Mpx; 704.2 KiB)
  3. 2,048 px × 1,136 px (2.3 Mpx; 1.4 MiB)
  4. 2,700 px × 1,500 px (4.0 Mpx; 2.1 MiB)

The below video compares:

Download:
  1. 512 px × 284 px (0.1 Mpx; 279.7 KiB)
  2. 1,024 px × 568 px (0.6 Mpx; 690.2 KiB)
  3. 2,048 px × 1,136 px (2.3 Mpx; 1.4 MiB)
  4. 2,700 px × 1,500 px (4.0 Mpx; 2.1 MiB)

Watching the last two videos shows that at decent values of nang and prec there is no visual benefit to having more conservatism than simply a factor of two. Using the first plot, and taking the “cons=8.0; nang=33; prec=1250.0” combination as “correct”, then for the four metrics:

These are the three combinations that I will be using for my final results later on.

§6 Internal Voids

The Matochkin Strait, within the Novaya Zemlya archipelago, is yet another example of a narrow passage which gets closed off by the initial buffering of the land: it is approximately 600 metres wide at its narrowest point. Additionally, it is frozen over for most of the year; GST is not aware of frozen seas (it treats all seas as perfectly navigable). However, it is most interesting here because it shows an early example of how sailing around land can create holes in the ship’s Polygon. This demonstrates why, when writing GST, I could not save computational time by only buffering the exterior of the ship’s Polygon - I must also buffer each interior ring until it explicitly closes off.

Download:
  1. 512 px × 512 px (0.3 Mpx; 515.1 KiB)
  2. 1,024 px × 1,024 px (1.0 Mpx; 887.9 KiB)
  3. 1,800 px × 1,800 px (3.2 Mpx; 1.5 MiB)

Note how when the ship sails round the Southern and Northern tips of Novaya Zemlya, and then sails North and South on the open sea to meet itself, it creates a void to the West (on the East coast of Novaya Zemlya) which it must take some time to sail into. This would not have been captured if I had deleted all internal voids.

Also note how the above video excellently demonstrates that low values of nang and high values of prec result in a ship which sails around land very poorly: the red Polygon lags behind the green and blue Polygons by an awfully long way.

Another excellent example is the Boca Del Guafo. The area of sea south of the main port of Puerto Montt has a really quite complicated coastline and also is very close to where a ship sailing south from the Panama Canal collides with a ship sailing north from the Magellan Straits.

Download:
  1. 512 px × 512 px (0.3 Mpx; 149.2 KiB)
  2. 1,024 px × 1,024 px (1.0 Mpx; 336.7 KiB)
  3. 1,800 px × 1,800 px (3.2 Mpx; 610.7 KiB)

§7 Results

After all the above waffle, here are the final results:

Download:
  1. 512 px × 340 px (0.2 Mpx; 2.7 MiB)
  2. 1,024 px × 682 px (0.7 Mpx; 7.3 MiB)
  3. 2,048 px × 1,364 px (2.8 Mpx; 10.2 MiB)
  4. 2,700 px × 1,800 px (4.9 Mpx; 14.8 MiB)

The above video clearly demonstrates the benefit of both the Panama Canal and the Suez Canal. I am particularly impressed by the Panama Canal: from Portsmouth it basically doesn’t have any delay. Conversely, the Suez Canal does still have quite a delay, but this is due to France and Spain getting in the way and the ship having to sail the whole length of the Mediterranean. Interestingly, by the time the ship gets very close to the end, it hasn’t used any canal to get there: it has simultaneously gone over the North Pole and gone around the Horn Of Africa and Cape Horn. It really does depend on where you are going as to how useful the two canals are. Finally, the above video really does show the potential benefits to global shipping if the Northwest Passage opens up (frankly though, I would prefer it to stay closed: having a non-warming planet is better than slightly quicker global sailings).

As an aside, The CIA World Factbook has a nice PDF map of the world oceans and shipping routes which aligns nicely with the conclusions in this article.

§8 Diagnostics

I am embarrassed to say that GST took quite a long time to calculate the “best” combination in the above video (ironically, it isn’t the buffering that takes ages, it is the subtracting of land from the ship). Whilst it was running, I wrote some scripts to diagnose the complexity of the problem.

Firstly, how many Points are there along the coastlines?

Download:
  1. 512 px × 341 px (0.2 Mpx; 37.8 KiB)
  2. 1,024 px × 683 px (0.7 Mpx; 83.9 KiB)
  3. 2,048 px × 1,365 px (2.8 Mpx; 186.1 KiB)
  4. 2,700 px × 1,800 px (4.9 Mpx; 143.3 KiB)

Secondly, how many Points are there around the ship?

Download:
  1. 512 px × 341 px (0.2 Mpx; 48.5 KiB)
  2. 1,024 px × 683 px (0.7 Mpx; 128.4 KiB)
  3. 2,048 px × 1,365 px (2.8 Mpx; 329.4 KiB)
  4. 2,700 px × 1,800 px (4.9 Mpx; 262.7 KiB)

Thirdly, how long does it take to calculate each iteration step?

Download:
  1. 512 px × 341 px (0.2 Mpx; 64.5 KiB)
  2. 1,024 px × 683 px (0.7 Mpx; 167.8 KiB)
  3. 2,048 px × 1,365 px (2.8 Mpx; 417.3 KiB)
  4. 2,700 px × 1,800 px (4.9 Mpx; 297.1 KiB)

The spike at 5 days is the point where the ship crosses the North Pole (and the mapping between degrees and metres becomes degenerate). The drop at 16 days is the point where South America gets deleted as it has been completely encompassed by the ship.