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: http://mytracks.appspot.com/

USING R TO MAKE HEATMAPS

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 http://www.openstreetmap.org/


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.







Heatstops.png
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() +
  theme_nothing()



Transpoints.png

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() +
  coord_equal()+
  theme_nothing()



Contour.png

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) +
  geom_density2d(aes(x=X,y=Y,colour=..level..), 
     size=2, alpha =.7, data=Path) +
  scale_alpha(to = c(0, .9)) +
  scale_fill_identity() +
  coord_equal()+
  theme_nothing()




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.

http://www.stanford.edu/~mjockers/cgi-bin/drupal/node/25

http://stotastic.com/wordpress/2010/08/integrating-php-and-r/

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.

<html>
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<PRAGMA NO-CACHE>
<title>Heatmap</title>
<body>
<div>
<?php

	// 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
	sleep(60);

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

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 - http://java.dzone.com/articles/sun-java-6-ubuntu-1004-1010?utm_source=am6_feedtweet&utm_medium=twitter&utm_campaign=toya256ForRSS

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 ...

OTHER VISUALIZATIONS

Dots & Trails

Circle that follows cursor and leaves a fading trail

Moving dot.png

Processing Applet

http://www.tom-carden.co.uk/p5/fade2anycolour/applet/

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

Blur.png

Processing Applet

http://www.hardcorepawn.com/particles/

Processing demo of Metaballs

Metaball.png

Processing Applet

http://processing.org/learning/topics/metaball.html

Heat & Density Maps

Android activations mapped geographically

AndroidAcivation.jpg

http://www.engadget.com/2011/02/24/visualized-android-activations-mapped-geographically-chronolog/

Processing Heat Map

Heat.png

Processing Applet

http://www.deiasolutions.com/map/

Heat Map on Google Maps

Heatmap.png

http://www.heatmapapi.com/

Gheat.png

http://geoip.arpatubes.net/conficker/

http://code.google.com/p/gheat/

Density of Clicks on a Web Page

Webclicks.png

http://www.labsmedia.com/clickheat/index.html

Grid Heat Maps

Rheatmap.png


Jheatchart.png

Other

Processing Clock

Shows 12 hour analog clock and 24 digital clock

Clock.png

http://www.openprocessing.org/visuals/?visualID=11119

Open Street Map

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

OpenMapSmith.png

http://www.openstreetmap.org/

WEBSITE

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.

Templates

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

Map Styles and Selection of Parameters

cloudmade.com

Interactive Crime Density Map

CrimeMap.png

padmapper.com

PadMapperHeat.png

geocommons.com

Geocommonsdata.png

Other

(Very few of these links may actually be useful)