Using Rhino Grasshopper to draw and analyze .gpx files from Endomondo

In my work in the BIM group at Pihl I have been using Rhino + Grasshopper more and more. Rhino is an incredibly versatile 3D modelling program and Grasshopper is a scripting language for Rhino that has a graphical interface. The scripting is done by dragging and dropping components and connecting them with noodle-like strings, rather than writing lines and lines of code. This makes Grasshopper an extremely user friendly way into scripting for Rhino.

Lately I have been working a lot with the Rhino Grasshopper combination and getting to know the wealth of plug-ins that have been created for Grasshopper to extend it's functionality. I was lucky enough to be invited to a webinar with Luis Fraguada where he presented a plug-in package he personally has been developing on called gHowl. The package adds read/write functionality for spreadsheets, XML files, writes .KML for Google Earth and can request elevation data from Google Earth among other things.

This webinar inspired me to start trying out these plugins. I have recently got myself a racing bike and have been tracking my routes on Endomondo. It turns out that on Endomondo you can export your tracks to the .gpx format (GPS eXchange format) which is structured like XML. This created a perfect case for trying out gHowl.

I used the gHowl components to read a .gpx file from Endomondo. It turns out that it includes the following data:
  • Metadata about the user
  • Longitude, Latitude, points on the track
  • Elevation data for some points (not all)
  • Timestamp for all points
This is plenty of information. It allows plotting the track to Google Earth. It allows measuring total ascent or descent distance. It allows analyzing velocity and visualizing it in either Rhino or Google Earth. 

This is exactly what I tried. The process looks sort of like this:
  • Import gpx information into Grasshopper using gHowl. 
  • Extract longitude, latitude, timestamp. 
  • Since longitude, latitude cannot be used directly to get distances in meters, which is required for calculating velocity in km/h it has to be converted to a coordinate system that uses meters. The Universal Transverse Mercador Coordinate system does this. I found some python code online (by Han Ul Yoon) that converts from longitude/latitude to UTM. I used it with the GhPython plugin for Grasshopper. 
  • The distance between every two consecutive points on the track is calculated along with the time difference between each point and then the velocity for each segment.  
  • This is then visualized in the Rhino viewport using color gradients to represent the velocity on each segment.
GPX track visualized using the grasshopper script.
The result is a visualization of my track from Endomondo that is color coded based on the velocity on each segment. Green meaning lower velocity and red higher. 

A traffic crossing: Note how the velocity is reduced before and after crossing the junction.
Now that the track data has been acquired it can be analyzed and worked on more thoroughly. One could inspect velocity as a function of grade/slope or it could be exported to Google Earth via a kml file. The possibilities are many. 

If you would be interested in getting your hands on the script or learning more about it, catch me on twitter: @hjorturs

8 comments:

  1. I would love to get this script to work and am having trouble. I am pretty new to Grasshopper. Any help would be awesome!
    Thanks
    Victor

    vczulak@gmail.com

    ReplyDelete
  2. Could you share this definition?
    ciudaddelaconcepcion@gmail.com
    Thanks!

    ReplyDelete
  3. Sounds cool! Would be cool to see the route visualised as an extruded line, giving the points a height in relation to the speed. Elevating each point up with a multiplication factor from the speed value, creating a polyline between the original route points (Z=0) and another polyline between the elevated points (Z=X) and then 2railsweep between these two polyline? :)

    ReplyDelete
  4. Good idea! I will have to give it a try :)

    ReplyDelete
  5. Hey, great info! Thanks for sharing it! I am new to Grasshoper, trying to figure out more about it. I have been "joggling" with conversion tools to transform kml to gpx files and found kml2gpx.com platform to be really useful. I though sharing it with you.

    ReplyDelete
  6. I am new to Grasshoper...
    Could you share this definition?
    artemapochta@gmail.com
    Thanks!

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. This comment has been removed by a blog administrator.

    ReplyDelete