I chose to set the center of the map to the median of my latitudes and the median of my longitudes. I’ve done some biking when traveling, so median made more sense for me than mean. Finally we want to map our GPS data. There are several pch options to try.
Now, we’re reading in the GPX file. If you want help on parsing XML files, check out this (German) tutorial I made a while ago.
We already have nice dataframe now with all the information available in the GPX file for each position. Each position is defined by the latitude and longitude and we also have the elevation (altitude) available. Note, that the altitude ist quite noisy with GPS, we will see this in a minute.
Now, let’s calculate the distances between successive positions and the respective speed in this segment.
We will now use the OpenStreetMap package to get some maps from the internet and use them as a background for the track we just converted. There are several blocks for each map type. Check the comments in the first block what the different calls do.
First, we need to get the specific map. The ‘type’ argument controls which type of map we get.
This next step is important and it took me a while to figure this out. We need to convert the maps we got with the function openmap() to a projection that fits our longitude-latitude format of positions. This will distort the maps in the plots a little. But we need this step because the track has to fit the map!