How SailRouter works
Background for the curious: the science and mathematics behind the router, and the system it runs on, including where its data comes from and what leaves the boat. You do not need any of this to use SailRouter; the rest of the handbook covers that. How to choose between the three routing algorithms is in Choosing the algorithm.
Science and mathematics
What the engine actually computes, and where the methods come from. References are collected at the end.
1. Isochrone routing
The core solver is isochrone expansion, applied to sailing vessels by Hagiwara [1]. An isochrone is the set of all positions reachable from the origin in a fixed elapsed time. The algorithm grows one isochrone from the last in discrete time steps until one of them reaches the destination, then walks the parent pointers back to recover the path.
At each step the frontier fans a set of candidate headings from every point it holds. For each heading the wind is read at that position and time, the boat speed is looked up in the polar at the resulting wind speed and angle, and the new position is projected forward along the geodesic. That produces a cloud of candidates, most of which are then discarded.
Bearing-bucket pruning
The candidate cloud is divided into narrow angular sectors, one degree wide by default, and only the best candidate in each sector survives. That keeps the frontier from collapsing onto a single heading while bounding its size, whatever the fan produced. The rule that decides which candidate is best is not fixed: the classical rule keeps the one furthest along, and where the water is land-dense the router instead keeps the one closest to the destination by water rather than by straight line (see Choosing the algorithm).
Time step
The step defaults to fifteen minutes and is set by the distance and water-difficulty presets: minutes in an archipelago, hours on an ocean crossing. If the very first step produces no candidates at all, the router halves the step and tries again before giving up.
Multi-leg passages
A track with via points is solved leg by leg. The arrival time at one waypoint becomes the departure time for the next, so the forecast advances correctly across the whole passage rather than being frozen at the start.
Termination
The expansion ends when a frontier point falls inside a capture radius of the destination, or when the step limit or the forecast horizon is reached. A truncated route is reported as truncated rather than presented as an arrival.
Reverse isochrones
Optionally the same expander runs backwards from the destination at its arrival time. Each reverse isochrone is the set of positions from which the destination is still reachable in the time that remains, and overlaying the two families at the same instant gives the strategic envelope: how much room the plan actually has. It doubles the compute, so it is off by default.
2. The polar and how it is read
Boat speed is a function of true wind speed and true wind angle. A published polar gives that function at grid points, typically 4 to 30 knots in 2-knot steps and 30 to 180 degrees in 5 or 10 degree steps, and is symmetric about zero, so one side is stored and mirrored on lookup.
Bilinear interpolation
Between grid points the speed is interpolated bilinearly in the wind-speed and wind-angle plane. For a query inside the cell bounded by the four surrounding nodes:
v(s,a) = (1-t)(1-u)v00 + t(1-u)v10 + (1-t)u v01 + t u v11where t and u are the fractional positions inside the cell. At the edge of the grid values are clamped, never extrapolated, and the clamp is logged.
Light air
Below the lowest wind speed in the grid, linear extrapolation would have the boat sailing at two knots in one knot of wind. Speed is scaled quadratically instead:
v = v_min x (TWS / TWS_min)^2At half the lowest gridded wind the boat makes a quarter of the speed, which follows the quadratic relation between wind speed and aerodynamic force.
VMG optima
Velocity made good is the boat speed projected on the wind axis, v x cos(TWA). The upwind and downwind optima are found at load time by sweeping the angle at one-degree resolution for every wind speed in the grid. Those angles are the theoretical best beating and running angles, and the tack logic uses them.
No-sail and no-run zones
No boat points higher than some angle, and many are unhappy dead downwind, where the main blankets the headsail and the boat rolls. Both zones are enforced at lookup: inside them the polar returns zero. The downwind edge has a ramp rather than a cliff, so the router is not offered a discontinuity to exploit.
These zones are why a wider sailing envelope can produce a slower route. Legalising the polar's slowest angles lets a candidate that pinches towards the mark win its bearing bucket while crawling, where a narrower envelope would have made the boat bear away or motor and arrive sooner.
Performance factor, sails and derating
A published polar is an optimum measured in flat water with fresh crew and perfect trim. The performance factor scales the whole surface to what your boat actually does, and the sail recommended for a cell carries its own multiplier on top, so a tired sail can be down-rated without touching the polar file. Separate derating applies close-hauled, in light wind and in heavy wind, where published numbers are least honest.
3. Wind field interpolation
Weather models output wind on a regular latitude and longitude grid at discrete forecast hours. Wind at an arbitrary position and time is trilinear: bilinear in space between the four surrounding nodes, then linear in time between the two bounding forecast steps.
The u and v components are interpolated separately and converted to speed and direction only afterwards. Interpolating direction directly would average 350 degrees and 10 degrees into 180, which is exactly backwards.
Longitude is a circle
Global model output runs 0 to 360 degrees, area downloads run -180 to 180, and a download that straddles the 180th meridian runs past 180 on purpose so its axis stays monotonic. A query is unwrapped towards the centre of the data's own longitude axis, which handles all three without having to guess which convention a grid follows.
The same care applies further down: coastline polygons are shifted so an island split by the meridian is whole again before it is tested, segments are cut at the seam before they become geometry, and a drawn path is unwrapped along its own sequence so a passage across the seam draws as a short hop rather than a band across the map.
Sources
| Source | Resolution | Steps | Reach |
|---|---|---|---|
| GFS (NOAA) | 0.25 deg global | 3-hourly | 16 days |
| ECMWF open data | 0.25 deg global | 6-hourly | 10 days |
| Open-Meteo | global and regional models | hourly | 2 to 15 days by model |
| Regional models | 1 to 3 km (ICON-D2, AROME, HARMONIE, ALADIN, UKV and others) | hourly | 48 to 78 hours |
A limited-area model is only offered when the area you asked for lies entirely inside its domain, because a download that runs off the edge comes back with holes and a route computed through them is worse than no route. Domains are measured from the live service rather than taken from the provider's prose, since most of these grids are projected and their footprint is not a rectangle.
4. Geodesy
Distances and bearings are solved on the WGS84 ellipsoid [8], through pyproj and PROJ, which implement Karney's algorithms [9]. That is exact to well under a metre anywhere on Earth. The spherical haversine formula would be off by up to 0.3 percent, some three nautical miles over a thousand-mile passage, and a flat-earth approximation fails outright at high latitude.
The direct problem, from a position, a bearing and a distance to a new position, projects every candidate forward. The inverse problem, from two positions to a distance and bearing, assigns bearing buckets and tests convergence on the destination. Both run vectorised over whole arrays, because a single isochrone step asks thousands of them.
5. Land avoidance
Land avoidance is the feature that separates this from the closest open peer [10], which as of v0.3.6 still draws routes through islands despite having the hooks to prevent it.
The coastline
Shorelines come from the Global Self-consistent Hierarchical High-resolution Geography database, GSHHG, of Wessel and Smith [5]. Of its five resolutions SailRouter loads the high one, which resolves the islands and channels a boat actually threads.
Spatial indexing
At startup the polygons are merged and prepared, which builds the internal indexes that make a point-in-polygon test cheap, and an STRtree [11] indexes the individual polygons for coarse filtering. A single land check costs well under a millisecond, and the checks run in batches over numpy arrays.
Sampling a segment
Testing exact line-polygon intersection for every candidate is too expensive at this rate, so each segment is sampled along its length, seven points by default and more where the water is difficult. Any sample on land rejects the segment. A coast margin can be added to push routes off the shore, with the caveat that a large margin buffers both banks of a narrow channel into each other and seals it shut.
Beyond the coastline
Three more hazards are treated the same way. Depth from the bathymetry grids rejects a segment that would put the keel on the bottom, with an under-keel margin. Reef polygons from OpenStreetMap, added for the Great Barrier Reef, reject a segment crossing coral. And a corridor you have drawn overrides the coastline, because a canal or a dredged channel is water whatever the shoreline data says.
Repair
Every finished route is re-validated at higher sample density than the search used, and a confirmed crossing is patched locally rather than failing the route. If a patch cannot be found the route is still returned, marked as unrepaired, so you see the problem instead of a silent claim of success.
6. Bathymetry
Depth comes from the GEBCO 2025 global grid [12] at 15 arc-second resolution, about 450 m, with higher-resolution EMODnet grids for European waters where available. Regional subsets are fetched over OPeNDAP.
Contours are extracted with contourpy at the configured depth levels, from 5 m to 5000 m, and the extraction follows the viewport: the grid is subsampled when you are zoomed out and read at full resolution when you are zoomed in, and the resulting lines are simplified before they are sent to the browser. The same grids are what the router reads when shallow-water avoidance is on.
7. Ocean data
Waves and currents come from the Copernicus Marine Service [13], the European Union's operational oceanography programme. Copernicus is an ocean model and carries no wind product, so wind always comes from the atmospheric models.
| Field | Variables | Resolution | Steps |
|---|---|---|---|
| Waves, global | significant wave height | 0.083 deg | 3-hourly |
| Currents, global | surface u and v | 0.083 deg | 6-hourly |
| Waves, Mediterranean | significant wave height | 4.2 km | hourly |
| Currents, Mediterranean | surface u and v | 4.2 km | hourly |
How the router uses them
- Currents: applied as drift after each step. The current at the candidate position, multiplied by the time step, displaces the arrival position along the geodesic. That is what bends a route into a favourable stream and away from an adverse one.
- Waves: degrade boat speed above a threshold significant wave height. Below it there is no penalty; above it the speed is reduced at a configured rate per metre, with a floor so a big sea slows the boat rather than stopping it. The threshold and the rate come from the comfort axis, which is most of what separating comfort from racing means [4].
The Mediterranean products are selected automatically when the whole requested area lies inside their domain, on the same containment rule as the limited-area weather models.
8. Engine fallback
The router sweeps true wind angles from 35 to 165 degrees at the candidate's wind speed and takes the maximum attainable polar speed. If that maximum is below the boat's minimum sailing speed, every heading at that position is given engine speed. If the boat could sail at any angle, no engine candidate is created at all and the heading fan finds the angle on its own.
Assigning engine speed per heading instead would let the engine win pruning in sailable wind, which is a subtle way to produce a route that motors across a perfectly good breeze.
9. Adaptive polar
A published polar is wrong for a real boat by something like 5 to 15 percent, and the calibration that fixes it is normally done by hand. The adaptive polar ships today and works by proposal: it re-estimates the polar from the boat's own recordings and hands the skipper a per-cell diff to accept or reject.
The estimate
Each cell of the grid is updated as a conjugate Normal-Normal problem: the published value is the prior, the boat's observations in that cell are the evidence, and the posterior is a weighted compromise that leans on the published number where evidence is thin. It is numpy only, which is what lets it run on a Pi with no machine-learning stack aboard. A Gaussian process fit over the whole surface [6][14] is available where the libraries are installed, and falls back to the per-cell estimate where they are not.
Why the arithmetic is careful
- True wind is reconstructed: not read from the log. The stored wind field may hold a forecast value rather than a measurement, so fitting it would learn the forecast's bias. The fit converts the boat's own masthead and log readings to true wind and counts every sample it has to reject.
- Derating is divided out: before binning. The router multiplies the polar by the performance factor and the sail multiplier at lookup, so an observation has to be divided by the same product first, or accepting a proposal would apply the boat's shortfall twice.
- Evidence is counted in time: not in samples. Recordings sample every few minutes, so an hour on one point of sail is a dozen readings of one condition. A cell's effective sample size is the number of well-separated windows it was seen in, and cells below the threshold are left exactly as published.
The causal problem
Logged sailing data has a bias that no amount of data removes: the helm steers to a favourable angle because the conditions are favourable. The log therefore over-represents the angles the crew likes and under-represents the extremes, and a naive fit learns the crew's preferences as if they were the boat's capability. Pearl's framework [7] is the right language for this, and the candidate corrections are wind-stability and steering-quality filtering, propensity weighting by how likely the helm was to choose an angle, explicit modelling of the steering policy as a confounder, and stratification by wind stability, autopilot mode and sea state.
Filtering is in place today. The weighting and the explicit policy model are not, which is the main reason the feature proposes rather than applies.
Still ahead
Three pieces of the design are not built. Risk-aware routing, where the cost of a segment is its time plus a multiple of its uncertainty, so a risk-averse skipper can avoid conditions the boat is not well characterised in: the uncertainty is computed and stored, and nothing reads it yet. The sea-state extension, which adds wave height and period to the input space, because the same fifteen knots is a different boat speed in half a metre of chop and in two and a half metres of swell. And a per-sail hierarchy, so each sail is learned as a variation on the boat rather than from scratch.
10. Robustness and uncertainty
A deterministic route assumes the forecast is right, and forecasts diverge from reality as the horizon lengthens, badly beyond about 72 hours. Philpott and Mason [2] set out the stochastic version of the problem: optimise over a distribution of scenarios rather than one.
The sensitivity sweep is the practical form of that available today. It re-runs the route over a grid of perturbations to the boat's performance and the wind speed, and reports the spread of arrival times: a passage whose ETA barely moves is robust, one that swings by hours is a gamble. Full ensemble routing across the members of an ensemble forecast is the next step in the same direction.
11. Learned time-to-go
The pruning rules described above are geometric proxies for the thing that actually matters, which is how long the rest of the passage will take. That quantity can be learned: run the isochrone expander backwards from the destination and every point of every reverse envelope carries an exact time-to-go label, which is training data for a small network that scores candidates directly.
The infrastructure for this is in place and no trained model ships, so routing today is the classical path exactly. When a model is present it changes only which candidate survives its bucket, never the physics.
12. Instruments
Live data arrives as NMEA 0183 over TCP, from Signal K or any multiplexer. Sentences read: RMC, GGA and GLL for position, VTG for course and speed over ground, HDG and HDT for heading, MWV for apparent wind, VHW for speed through water, DPT and DBT for depth, TTM for radar targets and VDM for AIS traffic. The talker prefix is ignored, so any source dialect dispatches correctly.
Every field carries its own timestamp and is shown as stale after ten seconds without an update, because a frozen wind reading is more dangerous than a missing one. Raw sentences are written to daily-rotating logs kept for thirty days, which is the replay material for everything above.
References
Routing algorithms
- [1] Hagiwara, I. (1989). Weather routing of (sail-assisted) motor vessels. PhD thesis, Delft University of Technology. The foundational isochrone method for sailing vessels: the time-stepped wavefront and the bearing-bucket pruning used here.
- [2] Philpott, A.B. and Mason, A.J. (2001). Optimising yacht routes under uncertainty. 15th Chesapeake Sailing Yacht Symposium. Extends deterministic routing to weather scenarios, the basis for the robustness work.
- [3] Guo, H., Zou, Z. and Liu, Y. (2020). An improved isochrone method for ship weather routing. Journal of Marine Science and Technology 25(3). Modern refinements to pruning and convergence.
- [4] Mannarini, G. et al. (2016). VISIR-I: small vessel, loss estimation for weather routing in the Mediterranean Sea. Geoscientific Model Development 9. Operational routing with sea-state dependent performance; the case for taking waves seriously.
Geospatial data and methods
- [5] Wessel, P. and Smith, W.H.F. (1996). A global, self-consistent, hierarchical, high-resolution shoreline database. Journal of Geophysical Research 101(B4). GSHHG, the coastline behind land avoidance.
- [8] Vincenty, T. (1975). Direct and inverse solutions of geodesics on the ellipsoid with application of nested equations. Survey Review 23(176). Geodesic distance and bearing on the WGS84 ellipsoid.
- [9] Karney, C.F.F. (2013). Algorithms for geodesics. Journal of Geodesy 87(1). The improved geodesic algorithms with guaranteed convergence that PROJ implements.
- [11] Leutenegger, S.T., Lopez, M.A. and Edgington, J. (1997). STR: a simple and efficient algorithm for R-tree packing. 13th IEEE International Conference on Data Engineering. The spatial index over the coastline polygons.
- [12] GEBCO Compilation Group (2025). GEBCO 2025 Grid. Global bathymetry at 15 arc-second resolution, the source of the depth contours.
- [13] Copernicus Marine Service. Global ocean physics and wave analysis and forecast. The wave and current fields used for overlays and for routing.
Statistics and machine learning
- [6] Rasmussen, C.E. and Williams, C.K.I. (2006). Gaussian Processes for Machine Learning. MIT Press. The theory behind the optional Gaussian process fit of the polar surface.
- [7] Pearl, J. (2009). Causality: Models, Reasoning and Inference, 2nd edition. Cambridge University Press. The do-calculus framing of the selection bias in logged sailing data.
- [14] Stein, M.L. (1999). Interpolation of Spatial Data: Some Theory for Kriging. Springer. The Matern class of covariance functions; Matern 5/2 is chosen for the polar because it is smooth without being infinitely smooth.
Software
- [10] GWeatherRouting (GPL, Python, GTK). The closest open peer: isochrone routing with GRIB, polars and NMEA. As of v0.3.6 it has no working land avoidance and routes go through islands. Confirmed by hands-on testing.
- [15] OpenCPN Weather Routing plugin (GPL, C++). Working land avoidance over GSHHS polygons, in a desktop application with no client-server design. Studied during development.
System
What you are connected to, what it holds, and what it talks to.
How it works
One process runs on the boat's computer, typically a Raspberry Pi 5. At startup it loads the coastline, the boat's polar and the weather already on disk into memory, then serves this interface to every device on the boat's wifi. Everything you see in the browser is computed by that process. Routing needs no server anywhere else.
Where the data comes from
- Wind: downloaded from NOAA, ECMWF or Open-Meteo when you ask for it in the Weather & Ocean panel, and stored on the box. Used for routing and for the wind overlay.
- Waves and currents: downloaded from Copernicus Marine. Used for the overlays and, when the corresponding correction is on, by the router.
- Coastlines: GSHHG shoreline polygons, installed with the software and loaded at startup. Used for land avoidance and for the coastlines-only chart.
- Depth: GEBCO and, in European waters, EMODnet grids. Used for the depth contours and for shallow-water avoidance.
- Reefs: OpenStreetMap reef polygons, downloaded per region.
- Charts: OpenSeaMap tiles online, tile packs or your own .mbtiles files offline, or the coastline itself with no internet at all.
- Instruments: position, speed, wind, depth, AIS and radar from Signal K or any NMEA 0183 TCP source, broadcast to the browser five times a second. With no instrument source connected everything else still works.
What leaves the boat, and what does not
There is no telemetry and no analytics. Your tracks, routes, recordings, logbooks, crew list and boat configuration are files on the box and are never uploaded anywhere.
Five things do use the network, all of them either initiated by you or plainly visible. Weather, ocean, chart and reef downloads, which fetch data and send only the area you asked for. The licence check. Software updates, when you click them. Map tiles, when the base map is online. And the AI features, which send the loaded route and its context to the provider whose key you configured, and are hidden entirely when no key is set.
The Data usage tab in Settings counts all of it, boat-wide across every connected device, split by category, so a satellite link's bill has an explanation.
Raw NMEA is logged to daily files kept for thirty days, on the box, for replay and for learning the polar.
Performance on a Raspberry Pi 5
| Operation | Typical | Notes |
|---|---|---|
| Startup | about 8 s | Loads coastlines and polars |
| 80 nm coastal route | about 3 s | With land avoidance |
| 150 nm offshore route | 5 to 8 s | Open water |
| Weather download | 10 to 60 s | Depends on area and link |
| Land check | under 1 ms | Batched over the whole frontier |
Memory in normal use is roughly 150 to 300 MB with coastlines, polars and a forecast loaded.
Instrument sentences
| Sentence | Provides |
|---|---|
| RMC, GGA, GLL | position, speed and course over ground |
| VTG | course and speed over ground |
| HDG, HDT | compass heading |
| MWV | apparent wind angle and speed |
| VHW | speed through water |
| DPT, DBT | depth |
| TTM | radar targets |
| VDM | AIS traffic |
A value not refreshed for ten seconds is shown as stale rather than as current. The connection indicator reports whether the box has a live NMEA link, which is a different question from whether a particular value is arriving.
Built with
- Box: Python and FastAPI, numpy, Shapely, pyproj, xarray and contourpy, shipped as a compiled binary that needs no Python on the boat.
- Interface: TypeScript, Vue 3 and MapLibre GL JS, served by the same process, cached for offline use.
- Data: GFS, ECMWF and Open-Meteo for wind, Copernicus Marine for the ocean, GSHHG for coastlines, GEBCO and EMODnet for depth, OpenStreetMap for reefs, OpenSeaMap for charts, Windy for the animated weather view.
- Instruments: NMEA 0183 over TCP, from Signal K or any multiplexer.