Skip to main content
100%

Force Layout Oceanic Routing

✓ Published0🌍 Public
Aandrew-reid
Last edited Mar 16, 2017
Created on Mar 16, 2017

This example uses D3’s force simulation to compute animated ocean shipping routes between Lisbon, Luanda, and Colombo. A world map is drawn with a Mercator projection, and land masses are filled with a grid of fixed force nodes. Route waypoints are generated along straight-line paths between ports and connected with links; the simulation then lets these waypoints repel from land nodes, curving the routes around continents. Yellow lines visualize the force network during the simulation. After the simulation settles, a black cardinal spline is drawn through the waypoints and animated with a stroke-dashoffset transition to trace the final paths.

AI-generated description

The goal of this bl.ock is a basic proof of concept in using force-directed layouts to set paths.

The force does not always work on this layout, but one of the two should each time at a minimum.

All land has been covered in a regular grid of points, which are incorporated into the force simulation. The force runs for 100 iterations before drawing a final line. Each route is drawn along the shortest path between the end points, however, a number of points are added along the route (and a number over the start and end points). The points are linked together with force links. The new points are added to the force simulation and the simulation is started.

After 100 iterations, a splined line is drawn connecting the points that were added and then forced into a usually sea-only routing.

This simulation wouldn't be able to handle Lisbon to Colombo directly very well (the middle port is Luanda) as it's just a bit to indirect to achieve routinely with this approach.

Similar vizzes