Thursday, August 27, 2026

Automatic Motor Routing in qtVlm

Since the very onset of electronic position finding (from LORAN on up to GPS), we have taught that these aids are wonderful tools for telling us where we are, but we must still master traditional navigation skills, because the electronics will not tell us the best, safe, efficient route to where we want to go.

Well... that is still true, but there is now a huge new caveat to the topic: namely, most modern navigation apps, called electronic charting systems (ECS), offer some form of automatic routing. In short, they do indeed now offer to tell us how to get to where we want to go. 

When this first came out, we made jokes about their advertisements, because the results were terrible and dangerous. Some still are. 

But now, more sophisticated ECS like qtVlm have worked on this exercise using official electronic navigational charts (ENC) plus a lot more respect for traditional navigation routing that can be implemented, because of their careful rendition of the ENCs, which include more information than third party proprietary charts used by some apps.

In all cases, the ECS must warn the navigator to carefully check the results before activating the route and blindly following it, which would be negligent. This is, of course, also true with qtVlm automatic routes, but qtVlm already had in place a top quality route checker function, which can be applied to the routes with a button click, plus they present multiple alerts in areas that should be double checked.

qtVlm calls such routes "S57 Motor Routes," because they are based on S-57 internationally standardized ENC and the assumption is you are under power, so you can steer any direction you choose.

Then, when planning ahead and not in the boat already, you move the boat to the place you want to start, and then go to your desired destination and place a mark at that location, then right click that mark, and choose S57 Motor Route.  That will initiate the  computation of a proposed route (in the form of a pathway), taking multiple factors into account, which we go over below.

The route depends on the dimensions of our boat to account for water depth, bridge clearance, transiting locks, narrow channels, and even entering and leaving marinas! Also, there is the option for larger vessels to follow traffic separation schemes (TSS, "shipping lanes"), or (the default) for smaller recreational boat who would like to avoid traffic and must interact with the TSS according to Rule 10 in the COLREGS.

Prior to computing a route we need to enter a few permanent settings:

• Draft (keel depth below waterline, plus your safety margin)

• Air draft (max height above waterline, plus your safety margin)

• Length overall (A+B in the GPS location diagram)

• Beam (C+D in the GPS location diagram) 

• Intended start time and date

• Intended knotmeter speed (so you can export a route plan with times)

 If LOA (A+B)  > 20m (66 ft) you can choose to participate in TSS

The time and speed inputs are important to qtVlm, but not a usual input for other ECS, because qtVlm can load tide and current forecasts from the Operational Forecast System (OFS) model, which provides tide height and tidal currents across most US waters by GRIB download. When those data are loaded, or coastal current data from coastal models such as NCOM or RTOFS, the routes will take that into account when finding the most efficient route. 

Forecasted water depth can be accounted for because qtVlm has the unique capability to also extract from the OFS data the actual water depths at every point on the chart, so it will account for those when applying your draft and air draft plus safety factors.

If you do not have OFS water depth or current GRIB data loaded, then the motor route ignores both tide and current. The depths controlling the route will then be the depth areas between contours, which you can read with a cursor pick on the chart. If the depth area is 6 to 30 ft, meaning its shallow side is defined by the 6-ft depth contour, and you entered a draft plus safety factor of 8 ft, then the motor route will not cross the 6-ft contour.

On the other hand, with OFS tides loaded and the tide in the area is 5 ft during your selected time of the voyage, then that depth area is effectively 11 to 35 ft and the route could cross it.  Clearly in cases like this, we have to be sure we are traveling at the time we said we were — but there are various alerts to warn of deviations.  

(To be a bit more specific: in routes with tides, the computation does not use OFS tides + charted depths, but rather it uses the OFS water depth, which is computed based on its own digital bathymetry of the area.)

With OFS tidal currents loaded, you could have the option of passing either side of an island, with favorable current on one side and unfavorable on the other. The route would typically choose the favorable side. Without current data loaded, the choice of side could be different. 

Likewise, taking a notable shortcut under a bridge can depend on the tide height, because the charted clearance is relative to MHW. At near-zero tide, you could pick up a lot of extra clearance in some areas.

If you wish to avoid a particular region, qtVlm lets you draw in a barrier line or area that the route will not cross. 

Once the route is computed, you can view and export a detailed route log with times, distances, and headings on each leg. The export could be as CSV for printing or as a GPX file to load the actual route into another device.

The video below illustrates some of these features.


[ to be added ]






Monday, August 10, 2026

How the Fit-Slope Method Works

Since we first proposed the Fit-slope method many years ago, and have used it continually since then, I have just realized that the base reason the procedure works is not as obvious as we might have implied in various descriptions of it. The procedure does often lead to improved sight data; it is mentioned in the latest edition of Bowditch: American Practical Navigator. 

A look at basic least squares fit analysis forces us to find the subtlety that makes it such an important aid to celestial sight analysis. But first, a bit of background.

See also our new Fit-slope tool to expedite the analysis described at the end plus video demo.

__________

In celestial navigation, we take a series of sextant sights of a specific body whose height is changing with time, so we end up with a list of times (x) and sextant heights (y). Over a short period of time, the celestial body height changes in a linear way. But our measurements always include some random errors, along with possible systematic errors, as well as periodic blunders. The data points then scatter about a straight line that represents the rise or fall of the height with time as perceived from our moving vessel.

Random errors come from varying judgements on best alignment of the body and the horizon as well as random errors in reading and recording the time of the alignment. Systematic errors might be due to a fading horizon during an evening twilight session. Blunders happen by reading the micrometer incorrectly, or reading 12 on the sextant dial or watch, and then writing down 21.

Such sights might be for an LOP from any celestial body, or they could be a series of lunar distance measurements. The process and initial analysis we discuss here is the same.

We take a series of sights of any one body with the goal of getting just one value, a single time and height that best represents the series of measurements, hopefully averaging out at least the random errors, and catching and removing the blunders. An important procedure we follow to improve on this is to try to take at least 4 sights of 3 different bodies, as near to 120ยบ apart as possible, and we alternate the sights, rather than take all of one body, then all of the next. This method also ensures we get a fix as soon as possible, in case we are somehow interrupted.


An exception occurs with evening sights of Venus, because we can often get a whole series of Venus sights with a sharp bright horizon before we can even see the stars we want to combine with it.


We end up with 4 or 5 sights of each body, and do the following for each set. We plot the Hs (y) vs. time (x) and then draw a straight line through the points, which is intended to represent what the values would be if we did them all precisely. Then we can choose any point on this line to represent the full set of measurements of that body. 


Doing this by hand, we lay a clear plastic ruler on the data so as to go through the most points possible, adjusting the line to leave as many points above as below the line. The difference between any data point and the line is called the residual, with plus above and minus below. The goal is have the sum of these residuals near zero. Points notably off the line could be ignored or weighed less when choosing the line's position. Note we can move the line up and down and we can rotate it to get the best alignment. 


This process is essentially a manual "least squares fit" to a straight line. Using a spreadsheet program like Excel, we would plot the data and then add a linear trend line, which gives us the equation of the best fit line, y = a + bx, where b is the slope and a is the intercept, meaning value of y when x = 0.


Knowing this mathematically correct best-fit line (we get from Excel), we can compare it with what we get when doing it by eye, no math involved. And it turns out that with a bit of practice, the human eye can do a remarkably good job in choosing the best fit, and thus we do not really add much to the analysis with Excel—assuming that is all we wanted out of Excel: the best fit line so we could choose a single sight that we could consider an average of the set for that body.


I think of the above as standard procedure in cel nav, without introducing the Fit-slope Method, which we will look at now.


The principle behind the Fit-slope Method is simple: we can compute the slope of the Hs vs. time line, so when fitting the line, with Excel or by eye with a parallel plotter, we can keep the slope constant as we look for the best fit. That restricts the choice of best fit line position and hence our choice of best representative sight. 


We compute the slope by computing Hc1 at a time at the start of the sight session from the DR at that time (t1) and then again from the DR at the end of the sight session (Hc2 at t2). The slope of the line is then (Hc2-Hc1)/(t2-t1). Plotting by hand we do not need this numeric value, we just plot Hc2 and Hc1 on the same plot as the actual Hs sights and draw a line between them. These Hc values will need a new scale, because they differ from the Hs values by the sum of the altitude corrections. Once on the same plot, we just align a roller plotter with the computed slope and then move it up and down, without rotation, to find the best fit.


That is pretty much the extent of the explanation we have given on how to use the method, followed usually by a couple examples. The Fit-slope Method almost always leads to an improved fix from a set of sights.


____________


But if we look at the details of least squares fitting, we can see that the above discussion has not focused in on why the method actually gets us better averages. It is implied, but not stated, and now I want to clarify how this works


I will state the key points, then at the end show the related math derivations. 


As mentioned above, a linear least squares fit to a table of x vs. y values gives the equation of the best line as y = a + bx. That best-fit line will always pass through the mid point of each axis (x-bar, y-bar), which is called the centroid point of the data set. x-bar is the average of all the sight times and y-bar is the average of all the Hs values.


Thus if the whole goal of the process is to find a single point on the best fit line using all of the sights, then you do not have to plot anything at all. Just choose Hs (best) = the average of all Hs values, and assume this is the value at time T = the average of all the sight times. That collapses the entire analysis to just averaging all of the sight data you have.


A less obvious result to many—though mathematically even simpler—is, if you force the least squares fit to have a fixed, specific slope (i.e., constant b) then the best-fit line will also go through the same centroid point of the data set, and you could again choose the midpoints as best representative of the set. The Hs values at any other time than the centroid will be different, but if the goal is just find a single point on the best fit line, the centroid point will still do the job.


According to that analysis, there is no difference between fit-slope and no fit-slope on choosing a single sight to represent the best average of the set!


The subtlety underlying why the fit-sope gets us a better average in light of the above mathematical facts is that we have assumed we are averaging all of the sights in both cases. 


In most cases, however, we are not using the same set of data in both cases. When using the proper slope we can better tell which sights are likely wrong or outliers, and remove them from the computation of the average. When we change the sights in the average, the average changes, so there is not in practice a common sight solution to the fit-slope vs. no-fit slope solution. Removing only one sight in the set can have a notable effect on the fitted line and centroid value. 


In the end, the fit-slope method is not so much a mathematical result. It is simply a guide to helping the human navigator choose which sights belong in the full set to be averaged. It is easy to find sets of real data that show that using the right slope changes the sights we consider too high or too low. 


In good conditions, we are looking for small corrections to what we might consider a good set of sights to begin with. In poor conditions, with hit and miss sights, of say a sun popping in and out of the clouds, or sights in big seas where we have to wait for a good view of the real horizon, then we might have a large scatter in the data points and the fit slope method is a hope to pull an improved fix out of poor data.


Note that fitting with fixed slope (b) in Excel is not as easy as just "Add trend line" that fits both a and b, but as noted we can do this all manually just as fast or faster than with Excel.


Another note is for the fit-slope method, we must indeed compute the Hc at the beginning and end using some app or formula to get the right slope. Pub 229 does not work for this as we need values for specific DR positions and those corrections in Pub 229 are tedious, and Pub 249 is not accurate enough.


___________


Here is Claude's proof that the best fit line goes through the centroid without a fixed slope and also with a fixed slope.





Below is then the same proof for a fixed slope:




___________________


• They are samples of real data from the book Hawaii By Sextant.   

Sample data 1
hh,mm,ss,Hs-deg,Hs-min
14,55,12,28,50.2
14,56,34,29,03.2
15,01,40,29,55.6
15,15,25,31,55.2

Ref 1
14,55,00,28,35.7

Ref 2
15,16,00,32,12.5

Desired sight time
15,00,00

Known slope
14866.29

------------
Hawaii By Sextant, Prob 27, sights #38b, Capella (12)
7/21/1982z
C=232, S=7.6

DR 1455 = 22 07.8n, 155 08.1w, with Hc = 28 35.7
DR 1516 = 22 06.2n, 155 10.4w, with Hc = 32 12.5

=========================
Sample data 2
hh,mm,ss,Hs-deg,Hs-min
04,53,55,48,56.0
04,54,45,48,50.5
04,56,47,48,40.0
04,58,17,48,32.7
04,59,17,48,27.0

Ref 1
04,53,00,49,09.0

Ref 2
05,00,00,48,34.4

Desired sight time
04,56,00

Known slope
-7117.71

-------------------
Hawaii by Sextant, Prob 18, sights #28a, Jupiter
7/17/1982z
C=247, S=7.7

DR at 0453 = 27 47.0n, 144 39.4w, with Hc = 49 09.0
DR at 0500 = 27 46.6n, 144,30.0w, with Hc = 48 34.4

===========================
Sample data 3
hh,mm,ss,Hs-deg,Hs-min
05,35,24,22,44.8
05,37,08,23,09.0
05,38,19,23,23.2
05,40,06,23,49.0

Ref 1
05,30,00,21,24.0

Ref 2
05,40,00,23,42.1

Desired sight time
5,38,00

Known slope
19886.40

------------
Hawaii by Sextant, Prob 26, sights #37c, Altair (51)
7/21/1982z
C=217, S=5.7

DR 0530 = 22 49.7n, 154 05.1w, with Hc = 21 24.0
DR 0540 = 22 48.9n, 154 05.7w, with Hc = 23 42.1

=========================

The app only reads the data above the single dashed line.