Our client is a major hospital specializing in Cardiac Care looking out for perfect location for putting up its hoardings.

Step 1 -
Understanding the decision problem and marking out the research objectives.

Decision Problem :
The client wants to build/hire 4 billboards (hoardings) on which it wants to advertise their emergency numbers, ambulance services etc. Therefore DP is to select 4 locations in Delhi where billboards can be put up.

Research Obejctives :
1. Targeting the correct audience
2. Figuring out four pefect locations which could maximise the ffect of the hoardings.

City : Delhi
We picked up Delhi as our focal city beacuse we aimed at targetting the Wealthy Segement individuals/dignitaries who would be agreeing to pay the high end services charged by our reputed client.

Entities we picked up :

Embassy : due to more than 70+ embassies in Delhi we could achieve our aim at targeting the dignatries living in Delhi.

Malls and Airports : Being a good developed city with a good cluster of upper segment people residing in. Generally Malls will have footfall from all segments including wealthy segments. Airport area will help in targeting specific segment.

Step 2 - Load required packages. We will need httr, RCurl and jsonlite package in R Workspace. (If packages are not installed you can install them with install.packages(“packagename”))

library("RCurl")
## Warning: package 'RCurl' was built under R version 3.2.3
## Warning: package 'bitops' was built under R version 3.2.3
library("jsonlite")
## Warning: package 'jsonlite' was built under R version 3.2.3
library("plotGoogleMaps")
## Warning: package 'plotGoogleMaps' was built under R version 3.2.3
## Warning: package 'sp' was built under R version 3.2.3
## Warning: package 'spacetime' was built under R version 3.2.3
library("geosphere")
## Warning: package 'geosphere' was built under R version 3.2.3
key = "AIzaSyBAqhOKSQtlgOzG_Oci06RZsavFc7wD_AY"

# malls search
url = paste0("https://maps.googleapis.com/maps/api/place/radarsearch/json?&query=malls+in+delhi&types=shopping_mall&location=28.6139,77.2090&radius=9000&key=",key)
doc <- getURL(url)
x <- jsonlite::fromJSON(doc)
malls = x$results$geometry$location
head(malls)
##        lat      lng
## 1 28.54345 77.15684
## 2 28.54263 77.15575
## 3 28.56923 77.24177
## 4 28.66762 77.22844
## 5 28.61885 77.28616
## 6 28.55327 77.19372
# embassy
url = paste0("https://maps.googleapis.com/maps/api/place/radarsearch/json?&query=embassy+in+delhi&types=embassy&location=28.6139,77.2090&radius=9000&key=",key)
doc <- getURL(url)
x <- jsonlite::fromJSON(doc)
embassy = x$results$geometry$location
head(embassy)
##        lat      lng
## 1 28.59576 77.18769
## 2 28.59550 77.19201
## 3 28.58698 77.18356
## 4 28.59221 77.18572
## 5 28.58555 77.18361
## 6 28.59501 77.18725
# airport
url = paste0("https://maps.googleapis.com/maps/api/place/radarsearch/json?&query=airport+in+delhi&types=airport&location=28.6139,77.2090&radius=9000&key=",key)
doc <- getURL(url)
x <- jsonlite::fromJSON(doc)
airport = x$results$geometry$location
head(airport)
##        lat      lng
## 1 28.58341 77.20725
## 2 28.56537 77.12443
## 3 28.62464 77.13469
## 4 28.63144 77.22331
## 5 28.54786 77.12734
## 6 28.56272 77.11973
malls$type = "Mall"
airport$type = "Airport"
embassy$type = "Embassy"

data = rbind(malls,airport,embassy)
dim(data)
## [1] 409   3
write.csv(data,"delhi_places.csv", row.names = F)

###################################################################


# let's plot the malls and do clustering based on distance matrix

sample = malls
coordinates(sample) <-~ lng +lat # Create cordinates
proj4string(sample) = CRS('+proj=longlat +datum=WGS84') # Add Projections

m<-mcGoogleMaps(sample,zcol = "type", mapTypeId='ROADMAP') # Plot on Google maps
###################################################################

# let's plot the embassy and do clustering based on distance matrix

sample = embassy
coordinates(sample) <-~ lng +lat # Create cordinates
proj4string(sample) = CRS('+proj=longlat +datum=WGS84') # Add Projections

m<-mcGoogleMaps(sample,zcol = "type", mapTypeId='ROADMAP') # Plot on Google maps

# let's plot the airports and do clustering based on distance matrix

sample = airport
coordinates(sample) <-~ lng +lat # Create cordinates
proj4string(sample) = CRS('+proj=longlat +datum=WGS84') # Add Projections

m<-mcGoogleMaps(sample,zcol = "type", mapTypeId='ROADMAP') # Plot on Google maps

Cluster with all three entities in one single google map :

sample = data
coordinates(sample) <-~ lng +lat # Create cordinates
proj4string(sample) = CRS('+proj=longlat +datum=WGS84') # Add Projections

m<-mcGoogleMaps(sample,zcol = "type", mapTypeId='ROADMAP') # Plot on Google maps
single cluster

single cluster

Step 3 -

We are interested in getting information about false entities like Airport, Malls and Embessies in Delhi.We can get information about these entities from Google Entities list.

Basis of the clustering we can select following four locations for display of hoardings

1 Connaught Place : Its a big round shopping area which constitues all the major malls of the city and also cover some embassies.
2 West Gate Mall : It includes all the high end shopping brands outlets and multiplexes.
3 Shantipath : It covers all the embassies in Delhi.
4 Mahatama Gandhi Marg (Near Mansarovar Garden) : Its the highway connected to the International Airport plus the major malls in the city in the outskirts.