Tagged with Series: GPS Tracks

Mapping GPS Tracks in Google Earth

Even though I find the R solution easier, I'm sure not everyone agrees with me, so here's the Google Earth way to import a bunch of GPS tracks and map them:

Export to TCX

From inside Garmin Training Center or other GPS device software, export a huge TCX file with all your tracks.

Mapping in Google Earth

Opening your TCX file

Select File -> Open. Change the dropbox for "Files of type" to "Gps", and then find your file and open it. Make sure the "Create KML LineStrings" box is checked and the "Create KML Tracks" box is unchecked. This will save us some work later.

Import settings

Next, zoom in, zoom out, and recenter as desired. If you want North to be up, you can click the "N" in the compass in the upper right.

In the layers (bottom left), I personally like to check Roads and uncheck everything else.

In the places (just above layers), right click "GPS device" and select "Properties". Click over to the "Style, Color" tab, and then click "Share Style".

Share style

I like to use the following settings:


  • Color: red
  • Width: 3.0
  • Opacity: 100%


  • Opacity: 0%


  • Opacity: 0%

Example style and color settings

Make sure you've selected all the dates you want on the date slider. Then you can select "Print" to export to a PDF, or you can take a screenshot.

Export image

Date slider and final map

And that's all there is to it. Large maps may take a long time to load and edit.

This post is one part of my series on Mapping GPS Tracks.

Tagged , ,

Mapping GPS Tracks in R

This is an explanation of how I used R to combine all my GPS cycling tracks from my Garmin Forerunner 305.

Converting to CSV

You can convert pretty much any GPS data to .csv by using GPSBabel. For importing directly from my Garmin, I used the command:

gpsbabel -t -i garmin -f usb: -o unicsv -F out.csv

[Note: you'll probably need to work as root to access your device directly]

For importing from a .tcx file, you can use:

gpsbabel -t -i gtrnctr -f test2.tcx -o unicsv -F old.csv

Mapping in R

After converting to .csv, we'll have a file with several columns, such as latitude, longitude, date, and time. We can now easily import this into R.

gps <- read.csv("out.csv", 
    header = TRUE)

Next we want to load up ggmap and get our base map. To determine how zoomed in we are, we can set zoom and size. We can also choose the maptype, with options of terrain, satellite, roadmap, or hybrid (satellite + roadmap).

mapImageData <- get_googlemap(center = c(lon = median(gps$Longitude), lat = median(gps$Latitude)),
    zoom = 11,
# size = c(500, 500),
    maptype = c("terrain"))

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.

    extent = "device") + # takes out axes, etc.
    geom_point(aes(x = Longitude,
        y = Latitude),
    data = gps,
    colour = "red",
    size = 1,

All my metro Atlanta bike rides

Previously, I've used Google Earth to create these maps, but I actually found it to be easier and way less time and resource efficient to do it in R. The only tricky part was converting the data into .csv, and there are other ways to do that, if GPSBabel isn't working for you. You might also be interested in trying Google Earth for mapping your tracks, instead of R.

Here's the gist with the code.

This post is one part of my series on Mapping GPS Tracks.

Citations and Further Reading

pch = 20)

Tagged , , , , ,