GPSBabel/Usage from the command line

From OpenStreetMap Wiki
Jump to: navigation, search
Available languages — Using GPSBabel from the command line
Afrikaans Alemannisch aragonés asturianu azərbaycanca Bahasa Indonesia Bahasa Melayu Bân-lâm-gú Basa Jawa Baso Minangkabau bosanski brezhoneg català čeština dansk Deutsch eesti English español Esperanto estremeñu euskara français Frysk Gaeilge Gàidhlig galego Hausa hrvatski Igbo interlingua Interlingue isiXhosa isiZulu íslenska italiano Kiswahili Kreyòl ayisyen kréyòl gwadloupéyen Kurdî latviešu Lëtzebuergesch lietuvių magyar Malagasy Malti Nederlands Nedersaksies norsk bokmål norsk nynorsk occitan Oromoo oʻzbekcha/ўзбекча Plattdüütsch polski português português do Brasil română shqip slovenčina slovenščina Soomaaliga suomi svenska Tiếng Việt Türkçe Vahcuengh vèneto Wolof Yorùbá Zazaki српски / srpski беларуская български қазақша македонски монгол русский тоҷикӣ українська Ελληνικά Հայերեն ქართული नेपाली मराठी हिन्दी অসমীয়া বাংলা ਪੰਜਾਬੀ ગુજરાતી ଓଡ଼ିଆ தமிழ் తెలుగు ಕನ್ನಡ മലയാളം සිංහල ไทย မြန်မာဘာသာ ລາວ ភាសាខ្មែរ ⵜⴰⵎⴰⵣⵉⵖⵜ አማርኛ 한국어 日本語 中文(简体)‎ 吴语 粵語 中文(繁體)‎ ייִדיש עברית اردو العربية پښتو سنڌي فارسی ދިވެހިބަސް

This page details how to call the GPSBabel program from the command line. As with many powerful tools, the command line is where much of the interesting functionality lives. The trade-off is a small learning curve. For (GUI) alternatives, see GPSBabel or making GPX Tracks.

You can get more information by running gpsbabel -?, and by reading the README file.

Basic command

The basic command line looks like this:

gpsbabel [options] -i INTYPE -f INFILE -o OUTTYPE -F OUTFILE

where ‘INTYPE’ and 'OUTTYPE' are formats that GPSBabel understands and 'INFILE' and ‘OUTFILE’ are the locations of that data. That location can be either a file or the name of a physical device. For example a serial port may appear as 'com1' under Windows or '/dev/ttyS0' under Linux.

As an example, let us suppose you have latitude, longitude, and waypoint name in a file 'way.csv'

40.70175, -103.68998, First Waypoint
39.28553, -123.79357, Another point
42.49638, -108.72995, And a third

To convert this CSV file into the GPX format (file way.gpx) we use this command:

gpsbabel -i csv -f way.csv -o gpx -F way.gpx

Deconstructing the command line: '-i csv' using the comma separated value INTYPE. '-f way.csv' (note that is a lower case f) specifies the name of the input file (or the name of the input serial port). '-o gpx' specifies the output is GPX format. '-F way.gpx' (capital F) provides the name of the output file (or output serial port).

GPS device communication via serial or USB ports

Most of the following subsections' content only is relevant if you do not already have a GPX file (e.g. written by your GPS device or by a smartphone app).

GPSBabel directly supports Garmin, Magellan and Wintec GPS units. Connect your GPS to your serial port or USB port depending on your device type (for connecting serial receivers to USB ports see GPS Serial to USB). A Garmin serial GPS is specified -i garmin while a Magellan is -i magellan. Use the -f and -F parameters to specify the serial port for your GPS. Use -f when you read from the GPS and -F to write to the GPS. (NB, if the following commands do not appear to work on the Garmin units, check that the Interface Setting on the unit is set to "GARMIN" or "GARMIN DGPS").

Reading waypoints from a GPS

Here are some examples to read waypoints from a Garmin GPS and write them out to the GPX format file named 'waypoint.gpx.'


Under Windows assume the GPS is attached to the first serial port:

gpsbabel -i garmin -f com1 -o gpx -F waypoint.gpx

That sets the input type to the Garmin serial protocol to read data from the serial port and write it to a GPX format file named waypoint.gpx.

If instead the device is connected to the USB port:

gpsbabel -i garmin -f usb: -o gpx -F waypoint.gpx


Assume the GPS receiver is attached to the first serial port. (Need to run as a user who has rights to read the serial port, so some systems may require the program to run as root or with sudo.)

gpsbabel -i garmin -f /dev/ttyS0 -o gpx -F waypoint.gpx

If the device is connected to the USB port, try /dev/ttyUSB0 or usb:

gpsbabel -i garmin -f /dev/ttyUSB0 -o gpx -F waypoint.gpx
gpsbabel -i garmin -f usb: -o gpx -F waypoint.gpx

See also:, USB Garmin on GNU/Linux

If you have problems accessing the USB0 port on your Ubuntu Linux, you might want to read this discussion thread on Ubuntu Forums and remove the packages brltty and brltty-x11 (Braille support apparently breaks USB serial). Don't forget to power on the GPS unit first!

A maybe useful bash script: download track and waypoints

GPSBabel bash script for downloading tracks,waypoints & routes available from: gerkin


Under OSX assume the GPS is attached to a serial to USB adapter

gpsbabel -i garmin -f /dev/cu.usbserial0 -o gpx -F waypoint.gpx

Under OSX 10.8 there was no /dev/cu.usbserial0 but I found that this worked:

gpsbabel -i garmin -f usb: -o gpx -F waypoint.gpx

Track logs

To read track logs you add a '-t' in front of the input (-i) specifier. So to get tracklogs under Windows:

gpsbabel -t -i garmin -f com1 -o gpx -F tracklog.gpx


And in the same way, you can read or write routes with the -r parameter:

gpsbabel -r -i garmin -f com1 -o gpx -F route.gpx

Note: When you write a route a waypoint will be generated for each route point. This is annoying. Since waypoints have globally unique names, your route points will be renamed if they collide with another route (a common problem would be numeric names eg. "1" "2" being renamed to "1 1" "2 1" etc.) To prevent this happening use John Dally's patch for gpsbabel.

Writing data to a GPS

You can also write tracklogs, waypoints, and routes back to your gps by swapping the input and output parameters. To write waypoints from waypoint.gpx to a Garmin unit under Windows:

gpsbabel -i gpx -f waypoint.gpx -o garmin -F com1

Using Filters

See using filters with GPSBabel for information on using GPSBabel filters to edit your track.