Converting waypoints to text file with GPSBabel

GPSBabel is a great command-line app to convert just about any kind of GPS file to any other. You can use it to convert, say, a GPX tracklog to a KML file in one step:

gpsbabel -t -i gpx -f "2012-10-01 track.gpx" -o kml -F "2012-10-01 track.kml"
  • -t : convert tracks
  • -i gpx : input file is GPX format
  • -f “…” : input filename
  • -o kml : output filetype kml
  • -F “…” : output filename

Bash script to convert GPX waypoints to CSV

Put this in /usr/local/bin or other $PATH directory, and chmod +x to make it executable:

# gpsbabel script to convert GPX waypoints to CSV
LEN1=${#1}-3  # length of the filename
OUT=${1:0:$LEN1}csv  # convert the input filename to *.csv
echo Converting "$1" to $OUT
gpsbabel -w -i gpx -f "$1" -o unicsv,grid=4 -F "$OUT"


  • GPSBabel in a script will fail if there are spaces in the filename UNLESS you use quotes around the command argument $1 and $OUT.