Geo Tracking Spring 2011 Betsy

From CSclasswiki
Jump to: navigation, search

Project Page for CSC220, Fall 2010

Main Project Page

MY TRACKS -- The Android alternative to Walkmeter

Introduction to My Tracks - slightly out of date (2009) but still accurate.

My Tracks Homepage:


R and Visualizations

R script that generates this heatmap

Using R I explored three different ways of visualizing "hotspots" which depict the highest density traffic on the map. My final R script generates four different images that are plotted together in a grid for easy comparison.

The plots use an image of the smith campus map captured from

We chose to use Open Street Maps instead of Google Maps because it has the most up to date map online that shows recently built buildings, street changes and foot paths. It also has outlines of the buildings at Smith which may be useful in interpreting the traces.

This is the traditional "heatmap" and the main map that we wanted to create. Here the the "hot", ie darkest red spots have the highest density traffic. The heatmap is plotted over a map of the smith campus. As the density increases, the opacity of the heat map decreases so they appear more vibrant.

Example R code:

hot_map <- ggplot() +
  geom_tile(aes(x = lon, y = lat, fill = fill), data = OSMsmith) +
  geom_tile(aes(x = lon, y = lat, fill = density_s, 
    alpha = density_zeroone), data = kde_df) +
  scale_x_continuous('Longitude', limits = lon_range) + 
  scale_y_continuous('Latitude', limits = lat_range) +
  scale_alpha(to = c(0, .9)) +
  scale_fill_identity() +
  coord_equal() +


Before learning how to make heatmaps, we were able to show density with just a plot of the traces generated by the gps devices that we used. Each point is enlarged and made semi-transparent so that points that are close together will overlap and appear darker. This is the simplest way to show density of points on a map.

Example R code:

points_plot <- ggplot() +
  geom_tile(aes(x = lon, y = lat, fill = fill), data = OSMsmith) +
  geom_point(aes(x=X,y=Y), colour="blue", 
     size=4, alpha=1/4, data=Path) +
  scale_x_continuous('Longitude', limits = lon_range) + 
  scale_y_continuous('Latitude', limits = lat_range) +
  scale_alpha(to = c(0, .9)) +
  scale_fill_identity() +


The final type of plot we made was a contour plot. This shows density (the red area being the density) as if it were hight on a topographical map. Thus the contours are like cross-sections of a mountain where the top of the mountain is the spot with the higest density traffic.

Example R code:

contour_plot <- ggplot() +
  geom_tile(aes(x = lon, y = lat, fill = fill), data = OSMsmith) +
     size=2, alpha =.7, data=Path) +
  scale_alpha(to = c(0, .9)) +
  scale_fill_identity() +

My two main resources for this portion of the project were:

David Kahle's project on visualizing crime density in downtown Houston. [Crime in Downtown Houston, Texas ]

Dave Allen's Presentation on creating contour and ‘heat map’ graphs to display PITCHf/x data

R and php

"Two projects use PHP to provide a web interface to R. R_PHP_Online by Steve Chen (though it is unclear if this project is still active) is somewhat similar to the above Rcgi and Rweb. R-php is actively developed by Alfredo Pontillo and Angelo Mineo and provides both a web interface to R and a set of pre-specified analyses that need no R code input."

However, I found the most useful resources were sites that provided examples of R and php working side by side.

Ultimately, we want the images produced by the R program to be displayed on the project webpage. Using what I had seen in the examples, I made a very simple php script that executes the R script and displays the output. This is very simple, as long as R is installed on the computer, the proper packages have already been installed. The only major problem is that R can take over 5 minutes to generate an image, depending on how many pixels you want the resulting image to be. This is because we have a solid colored background (the map of smith). If just the heat spots/contour plot/etc could be generated by R and then superimposed onto the map of smith another way, it might save some time.


	// execute R script HeatMapOutput.R from shell
	// this will save a plot at smithheatmap.png to the filesystem
	shell_exec('R --vanilla < HeatMapOutput.R');
	// wait 60 seconds - a quick fix to give R enough time to produce the image

	$nocache = rand();
	echo("<img src='smithheatmap.png?$nocache' />");

Other unanswered questions include: Can we put a Php tunnel as the URL, allowing us to pass parameters? And how can we pass the parameters to R from the Web page? More information can be found at Data Import/Export in R

R and Java

Another potential goal for the future would be to incorporate R into Processing. R has been used with Java, and even with Processing in the R4P project, but getting it to actually work has proved to be very difficult.

R4P Project here

Info on Sun Java -

JRI is a Java/R Interface, which allows to run R inside Java applications as a single thread. It appears as though we could use this in processing ...


Dots & Trails

Circle that follows cursor and leaves a fading trail

Moving dot.png

Processing Applet

A test of 6 different fade/blur methods of trailing particles


Processing Applet

Processing demo of Metaballs


Processing Applet

Heat & Density Maps

Android activations mapped geographically


Processing Heat Map


Processing Applet

Heat Map on Google Maps



Density of Clicks on a Web Page


Grid Heat Maps




Processing Clock

Shows 12 hour analog clock and 24 digital clock


Open Street Map

Most up to date map of Smith that I have found -- complete with foot paths



We are looking for Web templates where we could find sophisticated sets of pages we can use for doing

  • student registration
  • selection of parameters
  • display of tracks.


  • Curious of what companies were claiming to be competators to squarespace I found:
    • - the Eden platform (focused less on blogging)
    • (much more business oriented)

Map Styles and Selection of Parameters

Interactive Crime Density Map





(Very few of these links may actually be useful)