Showing posts with label Location Analytics. Show all posts
Showing posts with label Location Analytics. Show all posts

Tuesday, January 24, 2012

Geocode your data using, R, JSON and Google Maps' Geocoding API

First and foremost, I absolutely love the topic of Location Analytics (Geo-Spatial Analysis) and see tremendous business potential in not so distant future.  I would go out on a limb to predict that the Location Analytics will soon go viral in the enterprise space because it has the capability to WOW us. Look no further than your iPhone or an Android phone and count how many location aware apps you have. We all have at lease one app - Google Maps.  Mobile is one of the strongest catalyst for enterprise adoption of Location aware apps. All right, enough of business talk, let's get dirty with the code.


Over the last year and half, I have faced numerous challenges with geocoding the data that I have used to showcase my passion for location analytics.  In 2012, I decided to take thing in my control and turned to R.  Here, I am sharing a simple R script that I wrote to geo-code my data whenever I needed it, even BIG Data.


To geocode my data, I use Google's Geocoding service which returns the geocoded data in a JSON. I will recommend that you register with Google Maps API and get a key if you have large amount of data and would do repeated geo coding.

Here is function that can be called repeatedly by other functions:

getGeoCode <- function(gcStr)
{
  library("RJSONIO") #Load Library
  gcStr <- gsub(' ','%20',gcStr) #Encode URL Parameters
 #Open Connection
 connectStr <- paste('http://maps.google.com/maps/api/geocode/json?sensor=false&address=',gcStr, sep="") 
  con <- url(connectStr)
  data.json <- fromJSON(paste(readLines(con), collapse=""))
  close(con)
#Flatten the received JSON
  data.json <- unlist(data.json)
  lat <- data.json["results.geometry.location.lat"]
  lng <- data.json["results.geometry.location.lng"]
  gcodes <- c(lat, lng)
  names(gcodes) <- c("Lat", "Lng")
  return (gcodes)
}

Let's put this function to test:
geoCodes <- getGeoCode("Palo Alto,California")

> geoCodes
           Lat            Lng 
  "37.4418834" "-122.1430195" 


You can run this on the entire column of a data frame or a data table:

Here  is my sample data frame with three columns - Opposition, Ground.Country and Toss. Two of the columns, you guessed it right, need geocoding.

> head(shortDS,10)
     Opposition              Ground.Country Toss
1      Pakistan            Karachi,Pakistan  won
2      Pakistan         Faisalabad,Pakistan lost
3      Pakistan             Lahore,Pakistan  won
4      Pakistan            Sialkot,Pakistan lost
5   New Zealand    Christchurch,New Zealand lost
6   New Zealand          Napier,New Zealand  won
7   New Zealand        Auckland,New Zealand  won
8       England              Lord's,England  won
9       England          Manchester,England lost
10      England            The Oval,England  won

To geo code this, here is a simple one liner I execute:

shortDS <- with(shortDS, data.frame(Opposition, Ground.Country, Toss,
                  laply(Ground.Country, function(val){getGeoCode(val)})))



> head(shortDS, 10)
    Opposition           Ground.Country Toss  Ground.Lat  Ground.Lng
1     Pakistan         Karachi,Pakistan  won   24.893379   67.028061
2     Pakistan      Faisalabad,Pakistan lost   31.408951   73.083458
3     Pakistan          Lahore,Pakistan  won    31.54505   74.340683
4     Pakistan         Sialkot,Pakistan lost  32.4972222  74.5361111
5  New Zealand Christchurch,New Zealand lost -43.5320544 172.6362254
6  New Zealand       Napier,New Zealand  won -39.4928444 176.9120178
7  New Zealand     Auckland,New Zealand  won -36.8484597 174.7633315
8      England           Lord's,England  won     51.5294     -0.1727
9      England       Manchester,England lost   53.479251   -2.247926
10     England         The Oval,England  won   51.369037   -2.378269



Happy Demoing and Coding!

Wednesday, December 21, 2011

Enterprise Software Spending to Slow Down - Business Analytics to the Rescue?

Few months ago, I floated this hypothesis that the software spending generally has a lag of 1-2 quarters to hardware spending and given that hardware spending is slowing down now with Cisco, Juniper, Brocade, EMC, NetApp, (and chip companies prior to that) all coming out with revenue and EPS warnings, software spending could slow as well further down the road.

Now, if ORCL’s  warnings from last night and following quote from an analyst were to be taken seriously, this hypothesis is unfortunately is coming true.  

                   Jason Maynard, an analyst at Wells Fargo Securities, said in a Dec. 19 report that corporate spending on hardware and software may fall 8 percent in the first quarter, a steeper drop than the average 7.3 percent average decline during the quarter in the past 10 years. (Source: Business Week )


The Enterprise Software Industry has enjoyed 12-13 quarters of continuous growth and it is a well-known fact that the spending is cyclical in nature.  May be, the industry should prepare for couple of quarters of slow growth (or no growth.) 

I am off the opinion that a full blown contraction in software spending will not occur. There is a pent up demand and those demand dollars are shifting to the cloud for SaaS, PaaS, IaaS and all other types of aaS as these XaaS become a preferred choice. That is precisely what may have caused the bloody hiccups (the reaction on Oracle's stock in financial markets) at Oracle.

This may be just an aberration for the tech industry and it may require new economy companies to prove that is just an aberration and not a trend . (Please see this blog - Oracle earnings - an aberration or a trend? )

Coming to the Analytics topic - in good times or bad times, more so in bad times, business analytics has become a tool of necessity, a must-have weapon to understand what levers to pull to run the business more effectively, more efficiently and identify the right resources to be delivered to grow and optimize the business in tough times.  


Data is a strategic asset and Business Analytics provides tactical tools to exploit that asset, companies will mine data even deeper with more sophisticated tools to get even more deeper insights if the signs of slow down loom on the horizon.

It is yet to be seen that the business spending on analytics will slow as well.  I will take a different stance here and will form another hypothesis that the spending will likely increase over the next couple of quarters.

Friday, September 16, 2011

Best quotes from Forbes Article SAP-Google Maps Partnership


SAP Partnership with Google Maps Indicates a New Openness

"SAP is overcoming a legacy of an insular engineering culture that could accurately be accused of suffering from a “not invented here” complex in the past."


"The only problem with SAP’s pride in its history is that it has sometimes shut the company’s eyes to new ways of creating software. It appears that this announcement may mark a turning point to increased awareness and use of outside components. If SAP becomes truly open to using more and more outside components, and learns how to use them to create stable, reliable software, SAP could accelerate the pace of change, keeping the stable parts of its applications, but adding the best of what has newly arrived."


There is something more at stake for Google than money - it is likely that Google Maps will be adapted by Google to better meet the needs of enterprise applications.


"What’s next? What other cloud components will SAP start to incorporate? The second is: Is a bigger partnership possible? Google’s mission is “to organize the world’s information and make it universally accessible and useful.” Much of the information that runs the world is in SAP. Why aren’t Google and SAP working together to make it more universally accessible and useful?"

Pervasive Location Analytics − The Next Frontier to Fall In the Enterprise Software?

Geo-location and spatial intelligence is the strategic turning point for business analytics and BI. Location has become an essential part of the enterprise data and increasing number of enterprises have geo-coded their location data to build location-aware application to drive location-aware decisions. For example, by overlaying the foreclosure data, income data, and the data from its mortgage portfolio on a geo-chart, a regional mortgage bank assesses the risk of its mortgage portfolio and decides to take corrective actions. A fast food company uses the demographics data, the latest census data, and the historical sales of its stores to determine the location of its new restaurant. 
Slides from SAP TechEd 2011 Las Vegas - http://goo.gl/etkvI

Thursday, July 28, 2011

Google Maps - SAP - The press is humming...

Thanks to my friends in marketing...


SAP Now Allows Businesses To Layer Big Data With Google Maps And Earth

Leena Rao, TechCrunch
July 27, 2011
Also seen in: The Washington Post, The Wall Street Journal, NewsFactor, The Business Insider, 21st Century Networker, Maine Social Networking, Data Centers Canada

(385 tweets)


SAP Tying Analytics to Google Maps, Earth

Chris Kanaracus, IDG News
July 27, 2011
Also seen in: PCWorld, CIO, Network World, Wall Street Journal, Computerworld, PC Advisor, InfoWorld, Albuquerque Express, CFO World, ARNnet, ITworld, Good Gear Guide, Techworld, Computerworld Australia, Computerworld UK, ITBusiness.ca
(114 tweets)

Google Deal Lets SAP Customers Map Data
Doug Henschen, InformationWeek
July 27, 2011
(28 tweets)

 

Google and SAP Team-Up to Help You Visualize Big Data

Klint Finley, ReadWriteWeb
July 27, 2011
(128 tweets)

SAP, Google expand collaboration partnership, eye enterprise mashups
Larry Dignan, ZDNet
July 27, 2011
(39 tweets)

SAP and Google Maps Team Up to Visualize Corporate Data

Todd R. Weiss, CIO blog: Deciphering Enterprise Apps

July 27, 2011

(3 tweets)

 

SAP Geo-tagging Business Analytics Data with Google Maps

Clint Boulton, eWEEK

July 27, 2011

http://www.eweek.com/c/a/Enterprise-Applications/SAP-Geotagging-Business-Analytics-Data-with-Google-Maps-274375/

Also seen in: eWEEK Europe
(19 tweets)

SAP Invokes Google Maps to Put Data in Context

Mike Vizard, IT Business Edge

July 27, 2011

(2 tweets)

 

Google Plus SAP Deepen Ties, Deliver More Enterprise Integration

Courtney Bjorlin, ASUG News

July 27, 2011

(14 tweets)

Photos: Google Maps gives SAP's business intelligence a new direction
Tim Ferguson, Silicon.com
July 27, 2011
(6 tweets)

SAP and Google Put Business Analytics on the Map

Justin Kern, Information Management

July 27, 2011

http://www.information-management.com/news/business_intelligence_analytics_data_geospatial-10020840-1.html

Also seen in: Insurance Networking News
(10 tweets)

SAP and Google Partner for Geospatial Business Intelligence
Paul Shread, EnterpriseAppsToday
July 27, 2011
(7 tweets)

SAP, Google and geospatial analytics
Todd Morrison, SearchSAP
July 27, 2011
(3 tweets)

 

SAP and Google team up to mash up analytics and maps
Matt Hartley, Financial Post
July 27, 2011

http://business.financialpost.com/2011/07/27/sap-and-google-team-up-to-mash-up-analytics-and-maps/

(4 tweets)

 

The “Where” Dimension of Business Intelligence

Adrian Gonzalez, Logistics Viewpoints
July 27, 2011
(15 tweets)

SAP, Google team up to tie-in business analytics to Google Map

Brad Lemaire, Proactive Investors USA & Canada
July 27, 2011
(4 tweets)

Google and SAP Partner on Geo-Mapping

Chris Crum, WebProNews
July 27, 2011
(23 tweets)

Google and SAP Team Up for Geovisualization of Business Analytics

Matt Ball, Spatial Sustain
July 27, 2011
(5 tweets)

SAP Partnership With Google Allows Data Mapping on Google Maps
TechGadgetsWeb.com
July 27, 2011
(5 tweets)

Street Fight Daily: 07.27.11
David Hirschman, Street Fight Daily: Inside the Business of Hyperlocal
July 27, 2011
(0 tweets)

Media and Blogger Coverage – Headlines & Links Select Global Coverage

EMEA
Germany
Geo-Dienste: SAP verbündet sich mit Google
Sibylle Gassner, Silicon.de
July 27, 2011
(4 tweets)

SAP und Google wollen gemeinsam Geodaten sammeln
Jens Hartmann, Silicon.de
July 27, 2011
(10 tweets)

SAP und Google rücken zusammen
Corrina Visser, Der Tagesspiegel
July 27, 2011
(1 tweet)

Netherlands
SAP, Google team up to pair enterprise apps with LBS tools
Telecompaper
July 27, 2011                 
(2 tweets)

Switzerland
Big Data: SAP married with Google Maps and Google Earth/ Big Data: SAP verheiratet sich mit Google Maps und Google Eart
Inside-it.ch
July 27, 2011
(0 tweets)

UK

SAP's Google partnership adds mapping data to business intelligence

Phil Muncaster, V3.co.uk
July 27, 2011
(0 tweets)

SAP and Google plan ‘big data’ Maps
Tom Brewster, ITPro
July 27, 2011
(13 tweets)

SAP & Google Partner For Enhanced Location-Based Analytics
ITProPortal
July 27, 2011
(5 tweets)

SAP sees double-digit growth in software sales

Computing.co.uk
July 27, 2011
(1 tweets)

APJ 
India
SAP teams-up with Google to manage big data
CIOL India
July 27, 2011
(0 tweets)

SAP and Google Maps - Putting "Where" in the "What-When-Where" equation!

Organizations are looking for that x-factor to get competitive advantage. Could geo/location-enabled solutions offer the promise to deliver that x-factor?  I think so.  

Lets use couple of examples to understand this deal - where should Chipotle open its next franchise or where should BP drill its next well...  Geo-enabled solutions could help answer those questions. Yes, this is already happening and some of these companies have very sophisticated software to do this. But, these software solutions should be available for the masses - 

Here is my business explanation for this deal- 

  •         A large part of the world’s enterprise data resides in the SAP systems;
  •         And according to some estimates more than 80% of that enterprise data has a space dimension to it; 
  •     Increasing amount of organizations demand geo-spatial lenses to engage with the space dimension of their data; 
  •     Hence, this collaboration between the #1 enterprise software company and the #1 consumer Internet company to bring location-aware solutions to the market.


Go SAP-Google Maps!