This is my first attempt of using R. The final intention is to have heat map for certain type of events that occur in Dubai.
To plot a map using R studio, google maps / open street map library is required. To install Google map:
> install.packages("ggmap")
> install.packages ("ggplot2")
> install.packages("maps")
Note: If you want to install into specific file location then:
> install.packages("maps", lib="C:/Users/xxxx/Documents/R/win-library/3.1")
Once these packages are installed, A map of Dubai is obtained with just five lines of R code (including the loading of packages.)
> library("ggplot2")
> library("ggmap")
> library("maps")
> map <- get_map(location = 'Dubai', zoom=11)
Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=Dubai&zoom=11&size=640x640&scale=2&maptype=terrain&language=en-EN&sensor=false
Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Dubai&sensor=false
> ggmap(map)
To plot a map using R studio, google maps / open street map library is required. To install Google map:
> install.packages("ggmap")
> install.packages ("ggplot2")
> install.packages("maps")
Note: If you want to install into specific file location then:
> install.packages("maps", lib="C:/Users/xxxx/Documents/R/win-library/3.1")
Once these packages are installed, A map of Dubai is obtained with just five lines of R code (including the loading of packages.)
> library("ggplot2")
> library("ggmap")
> library("maps")
> map <- get_map(location = 'Dubai', zoom=11)
Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=Dubai&zoom=11&size=640x640&scale=2&maptype=terrain&language=en-EN&sensor=false
Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Dubai&sensor=false
> ggmap(map)
No comments:
Post a Comment