Plotting GPX tracks with Shiny and Leaflet

August 5, 2016

(This article was first published on Rcrastinate, and kindly contributed to R-bloggers)

Lately, I got the chance to play around with Shiny and Leaflet a lot – and it is really fun! So I decided to catch up on an old post of mine and build a Shiny application where you can upload your own GPX files and plot them directly in the browser.

Of course, you will need some GPX file to try it out. You can get an example file here (you gonna need to save it in a .gpx file with a text editor, though). Also, the Shiny application will always plot the first track saved in a GPX file. Also, only tracks are supported at the moment, no routes or waypoints. Basically, most sports tracker apps or devices produce such files.

Here’s the link to the GPX Shiny app:
(Please note that as soon as my free 25 active hours limit of is up, the app won’t work until the end of the current month. Also, sometimes the loading of map tiles is quite slow – there’s nothing I can do about that at my end.)

You can choose the type of map that is used and the color of your track. Also, the application throws an error if you upload a GPX file that cannot be parsed or a totally different file. For catching these errors, I’m using code I explained in another one of my posts. The error notification window is implemented using the shinyBS package. It’s pretty easy to use.

As soon as you upload a GPX file that can be parsed by the application, an elevation diagram appears in the right panel.

Here’s a screenshot of the Shiny application.

I really like how the input panel fades in and out upon hovering in or out. To realise this, I used the styles.css file available here. Also, the input panel is trackable.
Thanks again to all the nice people implementing R, Shiny, Leaflet and providing all the awesome map tiles – for free!

To leave a comment for the author, please follow the link and comment on their blog: Rcrastinate. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)