<commit_before>---
layout: post
title: "USA/ Canada Roadtrip 2016"
date: 2016-10-14
categories: maps gpx
tags: maps gpx ggplot2 ggmap XML Google_maps API
---

Mapping GPS data from our USA/ Canada Roadtrip
==============================================

This September we went on a roadtrip to the US and Canada. 
Of course, we had our trusty GPS to guide us along the way, the data from which I downloaded and used to play around with.

<br>

Loading the data
----------------

I used the **XML** package to load the gpx files following [this blog post](https://www.r-bloggers.com/stay-on-track-plotting-gps-tracks-with-r/).

``` r
library(XML)

myfiles <- list.files(path = "../gpx/gpx_files", full.names = TRUE)

for (i in 1:length(myfiles)){

  # One of the files seems to be broken, but since the file is one with earlier data
  # not from the trip, I will simply skip it
  tryCatch({
    pfile <- htmlTreeParse(myfiles[i], useInternalNodes = T)

  }, error=function(e){cat("ERROR\n")})

  if (exists("pfile")){
    # Get all elevations, times and coordinates via the respective xpath
    elevations <- as.numeric(as.character(xpathSApply(pfile, path = "//trkpt/ele", xmlValue)))<commit_msg>Update 2016-10-14-roadtrip2016.md<commit_after>---
layout: post
title: "USA/ Canada Roadtrip 2016"
date: 2016-10-14
categories: maps gpx
tags: maps gpx ggplot2 ggmap XML Google_maps API
---

Mapping GPS data from our USA/ Canada Roadtrip
==============================================

This September we went on a roadtrip to the US and Canada. 
Of course, we had our trusty GPS to guide us along the way - the data from which I downloaded and used to play around with.

<br>

Loading the data
----------------

I used the **XML** package to load the gpx files following [this blog post](https://www.r-bloggers.com/stay-on-track-plotting-gps-tracks-with-r/).

``` r
library(XML)

myfiles <- list.files(path = "../gpx/gpx_files", full.names = TRUE)

for (i in 1:length(myfiles)){

  # One of the files seems to be broken, but since the file is one with earlier data
  # not from the trip, I will simply skip it
  tryCatch({
    pfile <- htmlTreeParse(myfiles[i], useInternalNodes = T)

  }, error=function(e){cat("ERROR\n")})

  if (exists("pfile")){
    # Get all elevations, times and coordinates via the respective xpath
    elevations <- as.numeric(as.character(xpathSApply(pfile, path = "//trkpt/ele", xmlValue)))
{'fraction_non_alphanumeric': 0.16079569001243266, 'fraction_numerical': 0.016576875259013676, 'mean_word_length': 3.751968503937008, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7638287', 'n_tokens_mistral': 808, 'n_tokens_neox': 747, 'n_words': 288}