Summer Road Trips – Light Blue circles indicate National Parks



My Location Heat Map While Attending Graduate School – Can you tell where I lived each of the two years? It was NOT on campus…

Screen Shot 2017-09-19 at 9.39.06 PM.png

My Overall Heatmap of Austin

Screen Shot 2017-09-19 at 10.32.31 PM.png


I have been using Google Timeline to track my location since 2013, and have finally gotten around to figuring out what to do with it. Using RStudio and the “jsonlite” and “plyr” packages, we can organize and display this data in more aesthetically pleasing ways than the simple timeline view google gives us.

‘The first step is to install the packages in RStdio

data <- fromJSON("location.json")

import your JSON file, file name is “location.json” in my case

locs <- data$locations

ldf <- data.frame(t=rep(0,nrow(locs)))

# Time is in POSIX * 1000 (milliseconds) format, convert it to useful scale...
ldf$t <- as.numeric(locs$timestampMs)/1000
class(ldf$t) <- 'POSIXct'

# Convert longitude and lattitude
ldf$lat <- as.numeric(locs$latitudeE7/1E7)
ldf$lon <- as.numeric(locs$longitudeE7/1E7)

Now that our data is in a useful form, we can turn the dataframe into a map. From here on out, your code may and should be different in some parts.

require(ggplot2) #install these packages if you haven't done so

ldfSummer <- ldf[29627:153800,]

Here in this code above, I am selecting a particular range of rows from my dataframe [29627:153800,] that represent Summer 2017, to create a map of just this summer. I do this again later in the code, to subset a different timeframe.

ldfGradSchool <- ldf[10438:848405,]
ldfGradSchool$ID <- 1:nrow(ldfGradSchool)
ldfSummer$ID <- 1:nrow(ldfSummer) #creating a new column for creating a gradient of colors based on time (not actual timestamp / not accurate)

Austin <- get_map(c(-97.7431,30.2672), zoom = 13, source='stamen',maptype="watercolor") #watercolor, terrain, toner are options

Stamen is a really cool group that makes map-type tiles.

Campus <- get_map(c(-97.737658, 30.286248), zoom = 15, source = 'stamen', maptype = "toner")
USA <- get_map(c(-108.239,40.410), zoom = 4, source = 'stamen', maptype = "watercolor")
USA <- get_map(c(-108.239,40.410), zoom = 4, source = 'stamen', maptype = "terrain") #depending on what map type you want

When making your map, you will need to experiment with the zoom level, the GPS coordinates for the center, the alpha level (opacity of the point), the maptype, and probably much more.

ggmap(Austin) + geom_point(data=ldf,aes(lon,lat),color="SteelBlue", alpha = .01) +
ggtitle("Austin, Tx") + xlab(" ") + ylab(" ")

ggmap(Austin, darken = c(0.45, "white")) +
geom_point(data=ldfGradSchool,aes(lon,lat),color = "RoyalBlue", alpha = .12, size = 1)
#GradSchoolAustin #darken function lowers the opacity of the map

ggmap(Campus) + geom_point(data=ldfGradSchool,aes(lon,lat),color = "SteelBlue", alpha = .15, size = 1)

ggmap(USA) + geom_point(data=ldfSummer,aes(lon,lat),color="SteelBlue", alpha = .03, size = 4) +
ggtitle("Summer") + xlab(" ") + ylab(" ") +
geom_point(data = nattyparks, aes(lon, lat), color = "skyblue", size =4, alpha= .8, shape = 1, stroke = 3) # Trip

All of these ggmap snippets are all examples of maps I created using this.


This project was made possible by StackExchange, Google, Stamen, and this original post by Rob

Download the R code itself here


Map tiles by Stamen Design under CC BY 3.0
“Map data by OpenStreetMap, under ODbL.”
Used under the creative commons license.
Adaptions were made to the original Maps.