Calculating the average elevation of a trip using a TCX file

If you use a site like ridewithgps, something you may want to know is how to calculate the average elevation for a trip. Unfortunately, most sites don't seem to provide this, so we have to do a little hacking.

Here's what worked for me:

  • download the GPS TCX file
  • grep out the altitude lines (grep -i 'altitude' your_file.tcx)
  • find & replace out the remaining XML tags and whitespace using a basic text editor
  • average the remaining values in a spreadsheet

Takes about five minutes. For my trip the number came out to be 10,753 feet!