📜 ⬆️ ⬇️

Year with Runkeeper: Analysis and visualization of geodata about your travels


Translation of the post Bernat Espigulé-Pons " A Year of Runkeeper: Analysis and Visualization ".
The code in this article can be downloaded here , and additional files here .
Many thanks to Kirill Guzenko KirillGuzenko for his help in translating and preparing the publication.
Almost a year ago, I decided to record all my movements with the help of Runkeeper , and now I want to present several options for visualizing my annual activity. The project is simple: I will load the data on my movements from Runkeeper, and analyze / visualize them in Wolfram Language . In this animation (see below) my movements in Barcelona are shown, and I will show you how to do the same.



Following the instructions on this page , I export my data from Runkeeper. There is another way - to connect my Runkeeper account to Wolfram Language using the ServiceConnect function. However, using this function, you can analyze only 25 movements, so this time I will export the data manually.

So, as a result, I got a ZIP file with a pair of CSV files, and also all of my previously recorded GPX files. First of all, I will save the laptop (Mathematica file) in the directory in which I unpacked the archive, and then I will assign this directory as the main one:
')


Now let's look at the first line of the cardioActivities.csv file:



In Runkeeper, you can take several measurements at once with different elements. To interpret these values ​​correctly, I use the SemanticImport function with the following column types:





As a result, I get a dataset object that is easy to analyze. Let's work with the data:

1. We calculate how many times and in what way I moved:



2. Calculate the average distance:



3. Construct a histogram of all distances:



4. Use the DateListStepPlot function to visualize the average speed of movement:



5. Choose a trip longer than 10 miles:





6. Find out how many times I would climb Everest:



7. Group the activities according to their description:



8. Select events marked “Boston” and import their GPX files:



9. Denote on the map the starting point for all modes of movement:



10. Last but not least, use the TimelinePlot function for all types of movement:



So far, so good. Next we need to pull the data from the GPX files. Using the Import and GeoGraphics functions , we will build a GPS track, marking it with a black line.



But I want to get more data about the height at which I was, and the speed with which I moved. The Import function has the “Data” option, which allows you to access the GPX file for the Wolfram Language common form (lists, strings, etc.):



This document contains a list of elevation points and time stamps fixed by the GeoPosition function. Since I am only interested in points, I defined a function that finds my location, and used the TimeSeries function to determine the height at which I was located:



GPX data is represented as an association with a pair of keys:



Now you can create a DateListPlot graph, colored depending on the value of the function (height).



Or use the “Geometry” parameter: use the Rescale function for lifting points, and then color the GPS track depending on the height:



Now, using this data, you can calculate the instantaneous speed. Sander Huisman (Sander Huisman), a member of the Wolfram Community , recently showed how to calculate the instantaneous speed and color the GPS track. Below is a function that I defined to calculate instantaneous speed time series from GeoPosition points and time series of rises:



And now recall the previous example: DateListPlot can tell me when I made a stop during the hike:



During these short breaks, I stopped to photograph the rock formations that inspired Salvador Dali himself . Let's make a map of these stops by coloring the GPS track depending on the speed:



Now, when I can mark the points of my location, the height of the climb and determine the instantaneous speed of movement, all this can be combined into a new data set:



A year ago, I moved from the countryside to Barcelona:



To designate my movements in Barcelona, ​​I could use the GeoWithinQ or GeoDistance functions , but now these functions will not be needed: I made notes on my movements around the city:



First, I want to make sure that all my movements will be marked on a black and white uniform map without any markings, and then I will map my movements using the GeoGraphics function. For this, I added additional GeoStyling options for the GeoBackground to make a background of gray shades. I also added GeoScaleBar and limited the segment on the map using the GeoRange function:



In my opinion, looks good. We map all recorded movements:



I covered almost the entire city! If I mapped only the initial (yellow) and red (end) points, it would be clear where I live. In most cases, I traveled from one point to another using the city's bicycle-sharing system :



Let's now build a route that will allow us to visit all these places again in the shortest possible time:



To visit them all, you need to drive (pass) about 170 km:



Not bad, if you compare it with how much I have in a year:



What else did I notice when using the Runkeeper for a year: my path from point A (house) to point B (center of the hood) is constantly changing. The fact is, I am not sure yet that the best way to get there is by bicycle. TravelDirections function will help to look at the data in a new way:



Draw a “TravelPath” for three different values ​​of the TravelMethod travel method - “Biking” (by bicycle) (green), “Walking” (on foot) (blue), and “Driving” (driving) (red); however, not only is there an easy way to get from point A to point B:



The TravelDistance function tells us that the Walk path is the shortest:



However, this path passes through the center of Barcelona - Ciutat Vella (old town), which is a maze of medieval streets with restrictions for pedestrians, so it will take me an hour to get from point A to point B. TravelTime shows that the route “To bike faster:



I must say that this year I tried various ways to get to point B by bicycle. My favorite now is the “driving” way, marked in red:



Let's now build the schedules of all 55 trips, painted in accordance with the travel time.





The blue / green tracks are closest to the “Walk” option, and it looks like these are the shortest paths to point B. My record is about 13 minutes:



Average travel time is close to that predicted by TravelDirectionsData :



With this data, I can travel in time throughout the past year. In my next articles on GeoGraphics , I'm going to color the GPS tracks according to the speed of movement and add dates for each type of movement using the Tooltip function:



And now you can take each of the travel options separately and animate all my trips and trips around Barcelona for the year.

The code for creating animations is available at the end of this article in CDF format. I suggest using it to analyze your data from Runkeeper. Need more ideas? Pay attention to the article (link to the translation published on Habré) " Chasing yourself, or a great way to start your day ."



For questions about Wolfram technologies, write to info-russia@wolfram.com

Source: https://habr.com/ru/post/302462/


All Articles