The GPS eXchange file format is a quick and easy way to get geo-located points out of a tracking software such as Strava or MapMyRide. I hadn’t realized that it was in an .xml format until reading Hjörtur Sigurðsson’s blog post on positioning Endomondo information in GH. Sigurðsson doesn’t go into detail about how to develop the script, so I thought I’d play around with it and see how to get .gpx info into the GH environment. This script uses components from gHowl and Elk, feel free to click on any of the images to enlarge.

GPXGH_01

The first step is to create a link between GH and the .gpx file path. Save the .gpx file you’d like to use somewhere on your machine or server, and then use the File Path module to link the information into GH.

GPXGH_02

Use gHowl’s Xml Parser module to parse and understand the .xml data.

GPXGH_03

The .xml data will likely have some metadata at the top of your point list, use the Split Tree module to create a branch without this info. The Split Tree’s splitting input is inclusive, so you want to list the last branch you’d like to remove for the split.

GPXGH_11

The formatting may change depending on your .gpx source. In this case, the point coordinates were listed as separate items within a branch, so use list items to separate the different coordinates and then merge them back together in a Construct Point module.

GPXGH_12

Once the points are formatted, follow the same sequence I described in my tutorial on using Elk to Create Maps in Grasshopper. This requires finding a .osm file and SRTM data of the same area that you are mapping. This isn’t an overly elegant solution at the moment, but will allow you to position .gpx information within GH. Good luck!

  • Hjörtur Sigurðsson

    Thank you for the credit! You have an extremely interesting blog which I will be following from now on.

    • Thanks so much and feel free to send more of your work my way!