Showing posts with label Google. Show all posts
Showing posts with label Google. Show all posts

Friday, April 18, 2014

googleMap-ing with R; Communte Loop

There are two main routes I can take to get to work each day, the two make a comically circular commute when both are taken.

I thought I'd use that commute to try out yet another cool use case for R, GPS plotting with dynamically created HTML/JS using the googleVis package.

First we need some data points.

For simplicity I logged the GPS data using my phone with the GPS Logger for Android app. This app provides coordinates logged to .gpx, .kml, or comma delimited .txt files at a chosen interval.  A few metrics are included like elevation, speed and bearing.  I plotted my morning and evening commutes while driving two different routes to the office.

The code for this very simple, the gvisMap call to the Google  Maps API does almost all of the heavy lifting.  We simply pass gvisMap the latitude and longitude coordinates in the expected format (lat:lon) and then an optional label for each point plotted as a "Tip".  Here I chose elevation relative to sea level, but any parameter in the set could be chosen.



#googleVis must be installed
library(googleVis)
 
#Read in the gps files.  I used .txt, but .gpx can be used also, with preparation
gps418 <- read.csv("20140418.txt")
gps418_2 <- read.csv("20140418_2.txt")
 
#Add morning and evening commutes
gps418<-merge(gps418,gps418_2, all.x=TRUE, all.y=TRUE)
 
#Prepare Latitude and Longitude for gvisMap
gps418$latlon <- paste(gps418$lat,":",gps418$lon, sep="")
 
#Call gvisMap function, here I'm using elevation as a label
gpsTry <- gvisMap(gps418,"latlon", "elevation",
                  options=list(showTip=TRUE, showLine=TRUE, enableScrollWheel=TRUE,
                               mapType='hybrid', useMapTypeControl=TRUE,
                               width=1600,height=800))
 
#Plot (Send gvisMap generated HTML to browser at local address)
plot(gpsTry)
 
#Yeah, it's that easy
Created by Pretty R at inside-R.org


The results are automatically rendered as a local address in your browser with the generated HTML calling the Google API.  I've pasted the relevant portion here to display the map:



Hat tip to Geo-Kitchen, I noticed their post while doing this one.  I like the plot of my alma mater

Tuesday, January 14, 2014

Google Acquires Nest

In what seems to me like the perfect snapshot instagram of current technology trends, Google announced yesterday that it acquired the home automation pioneer, Nest.

Buying Nest, after forays into home energy data and hardware, seems like a great fit for Google.  Similar to the Android platform, Google is once again making use of hardware outsourcing (or corporate crowd sourcing) in order to focus on its core competency, smart data acquisition.

Nest's products are a great example of how known technology can be totally reinvented with the introduction of machine learning and UI enhancements.

The thermostat is no new product, and one of the most common technologies used in the sensing of temperature for thermostats has remained mostly unchanged over the past century since the first patent.  Simple circuits using thermistors can mimic the thermostat for less than $20.  Adding a fancy microcontroller only adds to the fun.  I've built a few temperature sensing projects which i hope to share in this space.

What makes the Nest thermostats and smoke detectors so exciting is the integration of the simple technology of household appliances and adding the relatively new and buzzy machine learning approach to existing technology.  A remote controlled thermostat is interesting, a bluetooth controlled thermostat might be fun, but an intelligent thermostat can actually change the way we interact with the technology.  Sensing and adapting to human behavior makes Nest's products both trendy and useful.



It has been my feeling for some time that consumer technology in this decade will be defined by the marriage of smart technology and big data.  Google's announcement only cements this path, and their place in the development of the machine learning era.