Using GPSBabel to Import Comma-separated-values

Electrical and electronic topics for small boats
jimh
Posts: 11673
Joined: Fri Oct 09, 2015 12:25 pm
Location: Michigan, Lower Peninsula
Contact:

Using GPSBabel to Import Comma-separated-values

Postby jimh » Tue Jun 27, 2017 3:19 pm

The freeware application GPSBabel is a very versatile tool for working with geo-position data. It can handle geo-position data in many, many formats. Today I got curious about using GPSBabel (the official release version not the development version) to convert data in comma-separated values (CSV) to the .GPX format. The CSV format is not documented very clearly. With some experimentation, I got it to work. Here is an example.

Using a text editor I created a simple one line text file. The file was named "testCSVinput" and it contained only this line:

45.00000, -83.00000, theWaypoint

The first number is the latitude, second number the longitude, and third text the name or description of the waypoint. Note that you have to enter the latitude and longitude as shown, in decimal degrees with exactly five decimal places. North latitude is a positive number. West longitude is a negative number. I don't know if there is a limit on the number of characters in the description.

Then I used GPSBabel to create a .GPX file. I selected the input file format to be "Comma separated values" and pointed to the test file. Then I selected the output format to be GPX XML and pointed to a directory for the output file to be created and specified the file name. Then I clicked "OK". Here is the application GPSBabel just after it converted the file:

screenShotGBSBabel.png
screenShotGBSBabel.png (75.14 KiB) Viewed 2992 times

Note that you don't type all that text into the lower text window; that window is filled by the output of the application as it runs. (The real application is not a graphical user interface, but the MacOS and Windows versions have a graphical user interface to simplify running the program.) You should select the input option TRACKS, even though you will be importing waypoints. If you don't the conversion fails.

The GPSBabel-created .GPX output file looks like this:

<?xml version="1.0" encoding="UTF-8"?>>
<gpx
version="1.1" creator="GPSBabel - http://www.gpsbabel.org" xmlns="http://www.topografix.com/GPX/1/1">
<metadata>
<time>
2017-06-27T18:58:24.380Z</time>
<bounds
minlat="45.000000000" minlon="-83.000000000" maxlat="45.000000000" maxlon="-83.000000000"/>
</metadata>
<wpt
lat="45.000000000" lon="-83.000000000">
<name>
theWaypoint</name>
<cmt>
theWaypoint</cmt>
<desc>
theWaypoint</desc>
</wpt>
</gpx>


As a final test, I imported the .GPX file into my chartplotter (PolarView NS); the chartplotter read the file and plotted the waypoint with no complaints. This demonstrates end-to-end creation-of-text-file to plotted-on-chartplotter functionality.

screenshotPolarViewNS.png
Waypoint plotted in chartplotter application POLARVIEW NS
screenshotPolarViewNS.png (151.51 KiB) Viewed 2986 times


Again, to create your own waypoints in a situation where you'd have to type them in manually no matter how you accomplished the task, you'd just type up all the waypoints in a text file using the formatting shown above. GPSBabel would turn that file into a .GPX formatted file for importing. It's free, and it takes no time at all to convert. And you can use your favorite text editor to create the big batch file, probably much faster than any chart plotter or navigation application could ever allow. Manually typing in data for waypoints in this way is very easy. Although there might be some chartplotter-specific navigation applications that can also do this, I think that using GPSBabel will probably much faster than any chart plotter or navigation application could ever allow. You can also organize the data easily; just create separate text files for waypoints you want to group together. This will allow you to more easily manage the waypoints by breaking them up into groups with a common area or purpose.

ASIDE: in order to figure out the format required for the input file in comma-separated-value format, I just had GPSBabel perform the reverse conversion, that is, I used a .GPX file I had and asked GPSBabel to output a file in its .CSV format. Once I saw how the data was translated, I was able to deduce the proper format for the input file.