Planning Multi-Day Cruises—GPX Tools

Note: The tools described in this post have been replaced with a more user-friendly online tool. Go to questeria.info/gpx/ to access this tool.

When cruising on Questeria, we like to have a route on our chartplotter. This makes for a less stressful day. When cruising for several days, we plan the routes ahead of time and organize them using Google Sheets. We use a number of tools in the process, some of which I created myself. Below is a snapshot of a spreadsheet with our routes. 

Routes
Spreadsheet of Routes

This spreadsheet contains seven routes, each on its own sheet. Each sheet contains waypoints, latitudes, longitudes, distances, bearings, durations and times. I will explain how I did this in this series of posts.

The last few posts talked about route planning tools we use before our cruise:

Shilajit Gold, often credited as the elixir from ancient Ayurveda, is known to enhance one’s overall buy viagra without rx physical, mental and sexual problems with time, but never get upset by the problem of getting age. The climb line viagra was a great metaphor for life. Moreover, they smoke, consume alcohol frequently and make use of therapeutic cialis generico mastercard devices to help with mobility or balance issues. Apart tadalafil canadian pharmacy from using herbal pills to increase testosterone naturally.

This post talks about two GPX tools; Clean Route and Convert GPX to CSV. The final post in this series will walk through an example using a route that I created as part of a trip from Florida Keys to Moore Haven, FL, and explain how I put the routes together in a spreadsheet and load them on our Garmin 4208 chartplotter and other devices.

GPX Files

Navigation programs like OpenCPN and HomePort use GPX files to import and export waypoints, routes and tracks. GPX files are a type of XML, eXtended Markup Language file. GPX file are text files—you can view them with a text editor or browser.

GPX files exported from OpenCPN are different than GPX files exported by HomePort and ActiveCaptain. There are enough similarities that they can be imported and used, but you lose or change some information. Some of the differences created by exporting and importing GPX files are easy to correct, but I created the Clean Route program to deal with things that aren’t as easy to fix. I created another program, Convert GPX to CSV, to extract data from a GPX file and put it in a CSV, Comma Separated Value, file that can be read as a spreadsheet.

I created these tools for my own use, and later decided to make them available on my website. Warning—they are not user friendly, but if you’re comfortable using a program without a nice user-interface, you may find these programs useful.

Background For GPX Tools

Some people might call me a dinosaur. I’m a retired software engineer who started before today’s standards were designed. During my career, if I needed a tool that wasn’t available, I created my own. In my personal life, as a boater and cruiser, I do the same. To better understand why I designed these tools the way I did, let’s go back in time to 1975…

I was fresh out of college and working at Bell Labs. I was working on processor diagnostic programs for an Electronic Switching System. I needed a random number generator to do some testing. One of my colleagues told me about a new operating system that Bell Labs had developed. It was called UNIX, and featured a new computer language called C. There was no Graphics, it was all alphanumeric command line. I created my tool, but first, I had to learn the system. Everything was short and cryptic—this was a style I adopted as my own.

As an aside, Unix and C became standards—most modern operating systems and languages, like Linux and C++, are based on them.

In the years that followed, I learned new languages and operating systems. I learned to use a Graphical-User-Interface ( GUI, pronounced Gooey), but I could always fall back to a command line interface when I needed to.

One of the languages I learned along the way is Perl. Perl is a good language for manipulating text files, like GPX files. It is an interpreted language, which means it needs another program to run, but it can run on many types of computers. There are free downloads of Perl available for personal use, such as ActivePerl.

Clean Route

In Planning Multi-Day Cruises—Overview, I talk about how I create a route and then refine it by importing and exporting between programs. The waypoint names, which are automatically assigned, are inconsistent and out of order. The waypoint symbols might be inconsistent and distract from the route. Sometimes waypoint names are displayed—this tends to clutter-up the screen. These are minor issues. I can modify each waypoint using OpenCPN or HomePort, but I wrote the Clean Route utility program to fix this.

The Clean Route program cleans up a route in a GPX file—it reorders the waypoints and cleans up symbols. You can specify the starting waypoint number, and the number of digits in the waypoint number. The default is to change the waypoint symbols to “Waypoint”, but you can specify another symbol name.

Setting Up Clean Route Program

Clean Route is written in Perl, and needs a Perl interpreter, like ActivePerl. To install ActivePerl, open www.activestate.com/products/activeperl/downloads/, and follow the instructions.

Clean Route is downloaded as a ZIP file. Go to questeria.info/toolsutil and click on the clntre.zip link and download the file to your computer.

Installation on Windows

Extract the files into a new or existing folder. The default is “C:\utils”. There are three files:

  • clnrte.txt — Readme file—short description of Clean Route.
  • clnrte.pl — Perl Script—requires a Perl interpreter, like ActivePerl.
  • clnrte.bat — DOS batch file—calls clnrte.pl with command line parameters, makes it easier to run from Command Prompt.
Adding Folder to PATH

Next, add the folder name to your PATH. This step is optional, but it makes it easier to run Clean Route from the command line.

  1. Open File Explorer, right-click This PC.
  2. Click Properties.
  3. In the System Properties window, click the Advanced system settings, and then click Environment Variables...
  4. In the System Variables window, highlight Path, and click Edit...
  5. In the Edit environment variable window, click New.
  6. In the highlighted field, type the full path of the folder for clnrte.bat. For example, C:\utils.
  7. Click OK in all the windows. The new path will be used the next time a Command Prompt is opened.

Modify clnrte.bat to set folder name and/or add any default options. Open File Explorer, find clnrte.bat, right-click and select Edit. Most of the lines start with “REM”. These are comments that explain the function of the file. The important line is as follows:

perl "C:\utils\clnrte.pl" --noverbose %*

“perl” starts the Perl interpreter. “C:\utils\clnrte.pl” is the full path of the Clean Route program. Modify this if clnrte.pl is not in the C:\utils folder. Next, are any default options. You can change defaults here. For example, change “noverbose” to “verbose” or add “–noreorder” or “–nocleansym”. “%*” passes command line options to the Perl script.

Clean Route Syntax

clnrte [options] infile1.gpx [infile2.gpx …[infileN.gpx]]

where, “infile1.gpx infile2.gpx … infileN.gpx” are route files in GPX format. Items in square brackets [ ] are optional. See below for options.

Clean Route Options

The options are Linux-style flags. You can specify a short name with a single dash, or a long name with two dashes. Some of the options have positive and negative, like –reorder and –noreorder. The last option is the one that takes effect. This may be useful for changing a default in the clnrte.bat file (see above), and overriding it from the command line.

–help or -h — Display help message. Clean Route does not run.

–outfile or -o filename — Specify output file name. The default output file name is infile_cln.gpx.

–reorder or -r | –noreorder or -nor— Reorder/don’t reorder waypoint names (default is to reorder).

–start or -s # — Specify starting waypoint number, if reordering (default is 0). If this option is not specified, you will be prompted for a start number.

–digits or -d # — Specify minimum number of digits in waypoint name (default is 3).

–cleansym or -c | –nocleansym or -noc — Clean/Don’t clean waypoint symbols (default is to clean symbols).

wpsym or –w symname — Waypoint symbol name, if cleaning symbols, (default is ‘Waypoint’)

–verbose or -v | –noverbose or -nov — Verbose/Nonverbose mode. Displays details about the route cleaning. This is used for debugging. Default is –noverbose.

Using Clean Route

You can run Clean Route two ways, from a command prompt or from File Explorer. To run from a Command Prompt, open a Command Prompt window, by clicking the Windows icon, clicking on Windows System and selecting Command Prompt. At the Command Prompt, change directory to the folder with your route GPX file.

>cd \routes

If clnrte.bat is in your PATH, type “clnrte”, otherwise type the full path name, For example “C:\utils\clnrte.bat”. Follow that with any options and one or more route GPX files.

>clnrte [options] routefile1.gpx [routefile2.gpx […routefileN.gpx]]

Items in square brackets [ ] are optional. If you do not specify a starting waypoint number (-s or –start), you may be prompted for one. If Clean Route completes successfully, the cleaned route GPX files will be in “routefileX_cln.gpx” in the same folder.

To run Clean Route from File Explorer, open File Explorer and find the Route GPX file to clean. Right-click on the GPX file, select Open With and Choose another app. Uncheck Always use the app with .gpx files and select More apps. If you see clnrte.bat. select it. Otherwise, select Look for another app on this PC, which will bring up another File Explorer menu. Locate and select clnrte.bat, and click Open. You will get a Command Prompt as follows:

Please enter a waypoint starting number -> 

Type a starting number and press enter. The cleaned route will be in file “routefile_cln.gpx” in same folder, unless otherwise specified.

Convert GPX to CSV

The Convert GPX to CSV program extracts information from a GPX file and creates a CSV file that can be opened with a spreadsheet program, like Excel or Google Sheets. In addition to extracting the waypoint name, latitude and longitude, the program calculates the distance (in nautical miles and feet) and bearing between waypoints.

I originally wrote this utility so I could view information from my tracks in a spreadsheet, and look for things like the lowest depth on my track. But later, I modified it to work with routes so I could look at my routes in spreadsheet form.

Setting Up Convert GPX to CSV

Like Clean Route, Convert GPX to CSV is written in Perl, and needs a Perl interpreter. See Setting up Clean Route Program for instructions on setting up ActivePerl.

Convert GPX to CSV is downloaded as a ZIP file. Go to questeria.info/toolsutil and click on the gpx2csv.zip link and download the file to your computer.

Installation on Windows

Extract the files into a new or existing folder. The default is “C:\utils”. There are three files:

  • gpx2csv.txt — Readme file—short description of Convert GPX to CSV.
  • gpx2csv.pl — Perl Script—requires a Perl interpreter, like ActivePerl.
  • gpx2csv.bat — DOS batch file—calls gpx2csv.pl with command line parameters, makes it easier to run from Command Prompt.

Next, add the folder name to your PATH, if you have not done so for Clean Route. See Adding a Folder to PATH for instructions. This step is optional, but makes it easier to run Convert GPX to CSV from the Command Prompt.

Modify gpx2csv.bat to set folder name and/or add any default options. Open File. Explorer, find gpx2csv.bat, right-click and select Edit. Most of the lines start with “REM”. These are comments that explain the function of the file. The important line is as follows:

perl "C:\utils\gpx2csv.pl" --noverbose %*

“perl” starts the Perl interpreter. “C:\utils\gpx2csv.pl” is the full path of the Convert GPX to CSV program. Modify this if gpx2csv.pl is not in the C:\utils folder. Next, are any default options. You can change the defaults here. For example, change “noverbose” to “verbose”. “%*” passes command line options to the Perl script.

Using Convert GPX to CSV

Like Clean Route, you can run Convert GPX to CSV from a Command Prompt or use File Explorer. I normally run Convert GPX to CSV from a Command Prompt right after I run Clean Route. See Using Clean Route and substitute “gpx2csv” for “clnrte”. Here is a screenshot of running Clean Route and Convert GPX to CSV.

Running from Command Prompt

Unlike Clean Route, Convert GPX to CSV works on track files from our Garmin chartplotter. Here is a screenshot of the track from the return trip I discussed in Sailing, Anchoring and Apparent Wind.

Screenshot of Track in Excel Spreadsheet

The first column is Latitude, then Longitude, Date, Time, Depth in Feet, Elapsed Time, Distance in Nautical Miles, Distance in Feet, Speed in Knots, and Bearing. The first five columns are from the chartplotter. The last five are calculated by the program.

Organizing Routes in a Spreadsheet

I have a shared template on Google Sheets for organizing routes. Download it by clicking here. Start by copying it to your own spreadsheet. The spreadsheet has a template sheet, named RteFormat. The template has six rows of header. The first step is to customize your template. Change speed of 5.5 in cell D3 to your planned average speed, in knots. Then, change your Start, cell C4, to your planned departure date and time.

I keep RteFormat sheet as is, and duplicate it to create a new sheet for my route. To start, click on the RteFormat sheet and select Duplicate. Then click on Copy of RteFormat and select Rename…

Next, open the CSV file with Excel or Google Sheets. Then, select, copy and paste it into the formatted page.

The rows following the header have eleven columns of data as follows:

WP-OWW Route Spreadsheet
Screenshot of Route Spreadsheet
  • Waypoint — waypoint name
  • Latitude — latitude of waypoint
  • Longitude — longitude of waypoint
  • NM — distance between this and previous waypoint, in nautical miles
  • Feet — distance between this and previous waypoint, in feet
  • Bearing — bearing from previous waypoint to this waypoint in true degrees
  • Leg Duration — time to get from previous waypoint to this waypoint at specified boat speed
  • Tot. Duration — time to get from first waypoint to this waypoint at specified boat speed
  • Time at WP — arrival time at waypoint, based on start time and boat speed
  • NM to Dest. — distance to destination, in nautical miles
  • Time to Dest. — time to destination, based on boat speed

Summary

I wrote these tools for myself, but make them available for everyone. They are not required for planning multi-day cruises, but they can make the job easier.

The next, and last post in this series will be an example that puts it all together.