I’m a runner. In the past I used the Nike+ and Ipod, Garmin Watch and until recently TomTom Watch + Nike+ to analyze/visualize my runs. My current watch was dying so I bought a new one, with the hope of the possibility to extract the data from the watch and make my own UI.
It was somehow possible with Nike+ to retrieve each file under a json file. Unfortunately this app is not supported anymore since Nike+ website update. The other downside was that the json files were retrieved from the Nike+ website, so I still needed a connection to internet (which was my goal to bypass entirely online application for this specific reason)
With this new TomTom watch, we have access (offline) to the runs, only the format is a binary file. Luckily I found on github a decoder to this binary format that display (credits to Dan Lenski for the decoding of the TomTom ttbin binary format)
library(ggmap)
## Loading required package: ggplot2
library(ggplot2)
library(grid)
library(gridExtra)
df<-read.csv('./foo.csv')
tmp<-as.Date(df$date, format="%Y-%m-%d")
df$month<-as.numeric(format(tmp,'%m'))
df$month_name<-month.abb[df$month]
df$day<-as.numeric(format(tmp,'%d'))
#duration vs distance
pl<-ggplot(data=df,aes(x=distance,y=duration)) + geom_point(aes(color=type),size=3) + xlab('Distance [miles]') + ylab('Time [min]') + xlim(0,12) + ylim(0,120) + ggtitle(' Time vs. Distance')
p1<- pl + geom_smooth(aes(group=1),method='lm',formula=y~x,color='black',size=.5)
print(p1)
p11<-ggplot(df, aes(x=distance, y=duration)) + geom_point(aes(color=type),size=3) + facet_wrap(~month_name) + xlab('Distance [miles]') + ylab('Time [min]') + xlim(0,12) + ylim(0,120) + ggtitle(' Time vs. Distance') + facet_wrap(~month_name)
p11<- p11 + geom_smooth(aes(group=1),method='lm',formula=y~x,color='black',size=.5)
print(p11)
#bar plot distance per day
p2<-ggplot(df, aes(x=date, y=distance)) + geom_bar(aes(fill=type),stat="identity") + theme(axis.text.x = element_text(angle=90, hjust=1))
print(p2)
p22<-ggplot(df, aes(x=day, y=distance)) + geom_bar(aes(fill=type),stat="identity")+ facet_wrap(~month_name) + theme(axis.text.x = element_text(angle=90, hjust=1))
print(p22)
Using the package ggmap, I was able to retrieve the geolcation when I run outside. I have another python script to run over a single run and that produces a csv file (one per run) with the latitude and longitude data. Below is an example.
# open csv file with geolocation for last run
name = './Map2016-10-09-10-01-51.csv'
df2<-read.csv(name,sep='\t')
#find my geolocation
myLocation<-c(min(df2$correctLong)-.01 , min(df2$correctLat)-.01, max(df2$correctLong)+.01, max(df2$correctLat)+.01)
myMap <- get_map(location=myLocation,source="google", maptype="roadmap")
## Warning: bounding box given to google - spatial extent only approximate.
## converting bounding box to center/zoom specification. (experimental)
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=41.129658,-81.48423&zoom=14&size=640x640&scale=2&maptype=roadmap&language=en-EN&sensor=false
p3<- ggmap(myMap) + geom_point(aes(x = correctLong, y = correctLat), data = df2,alpha = .5, color="darkred", size = 0.05) + ggtitle(name) + xlab("longitude") + ylab("latitude")
print(p3)