<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/plotting-gpx-tracks-with-shiny-and-leaflet/"></div></div><div><a data-url="https://www.r-bloggers.com/plotting-gpx-tracks-with-shiny-and-leaflet/" data-counturl="https://www.r-bloggers.com/plotting-gpx-tracks-with-shiny-and-leaflet/" data-count="horizontal" data-text="Plotting GPX tracks with Shiny and Leaflet" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://rcrastinate.blogspot.com/2016/08/plotting-gpx-tracks-with-shiny-and.html"> Rcrastinate</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Lately, I got the chance to play around with <a target="_blank" href="http://shiny.rstudio.com/">Shiny</a> and <a target="_blank" href="http://leafletjs.com/">Leaflet</a> a lot – and it is really fun! So I decided to catch up on an <a target="_blank" href="http://rcrastinate.blogspot.de/2014/09/stay-on-track-plotting-gps-tracks-with-r.html">old post of mine</a> and build a Shiny application where you can upload your own GPX files and plot them directly in the browser.</p>
<p>Of course, you will need some GPX file to try it out. You can get an <a target="_blank" href="https://en.wikipedia.org/wiki/GPS_Exchange_Format#Sample_GPX_document">example file here</a> (you gonna need to save it in a .gpx file with a text editor, though). Also, the Shiny application will always plot the <b>first</b> track saved in a GPX file. Also, only <b>tracks</b> are supported at the moment, no routes or waypoints. Basically, most sports tracker apps or devices produce such files.</p>
<p>Here’s the link to the GPX Shiny app: <a target="_blank" href="https://rcrastinate.shinyapps.io/GPXshiny/">https://rcrastinate.shinyapps.io/GPXshiny/</a><br><span>(Please note that as soon as my free 25 active hours limit of shinyapps.io 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.)</span></p>
<p>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 <a target="_blank" href="http://rcrastinate.blogspot.de/2013/12/catching-errors-in-r-and-trying.html">another one of my posts</a>. The error notification window is implemented using the <a target="_blank" href="https://cran.r-project.org/web/packages/shinyBS/index.html">shinyBS package</a>. It’s pretty easy to use.</p>
<p>As soon as you upload a GPX file that can be parsed by the application, an elevation diagram appears in the right panel.</p>
<p>Here’s a screenshot of the Shiny application.
<div><a target="_blank" href="https://i0.wp.com/4.bp.blogspot.com/-8jxnwE-XQmk/V6HJNWEC08I/AAAAAAAACwI/ao1mr1TAe7QkXN74qkDktblbApK4f5YgwCLcB/s1600/shinyGPX.png?ssl=1"><img src="https://i1.wp.com/4.bp.blogspot.com/-8jxnwE-XQmk/V6HJNWEC08I/AAAAAAAACwI/ao1mr1TAe7QkXN74qkDktblbApK4f5YgwCLcB/s400/shinyGPX.png?resize=400%2C198&ssl=1" border="0" data-recalc-dims="1"></a></div>
<p>
<div></div>
<div>I really like how the input panel fades in and out upon hovering in or out. To realise this, I used the <a target="_blank" href="https://github.com/rstudio/shiny-examples/tree/master/063-superzip-example">styles.css file available here</a>. Also, the input panel is trackable.</div>
<div></div>
<div>Thanks again to all the nice people implementing R, Shiny, Leaflet and providing all the awesome map tiles – for free!</div>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="https://www.r-bloggers.com/plotting-gpx-tracks-with-shiny-and-leaflet/"></div></div><div><a data-url="https://www.r-bloggers.com/plotting-gpx-tracks-with-shiny-and-leaflet/" data-counturl="https://www.r-bloggers.com/plotting-gpx-tracks-with-shiny-and-leaflet/" data-count="vertical" data-text="Plotting GPX tracks with Shiny and Leaflet" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://rcrastinate.blogspot.com/2016/08/plotting-gpx-tracks-with-shiny-and.html"> Rcrastinate</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/N_k7Xx_1RNc"></a></div>