Last active
April 11, 2017 14:28
-
-
Save viveknarang/d60f9de8b5d3ec22859d793b692f5947 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################### | |
####################### Assignment A6 ######################### | |
####################################### Vivek Narang ########## | |
# Start # | |
# Importing Required Libraries # | |
library(ggplot2) | |
library(ggmap) | |
library(mapproj) | |
library(DBI) | |
library(RMySQL) | |
# Attempting to connect with the database wallaby.terry.uga.edu using credentials # | |
conn <- dbConnect(RMySQL::MySQL(), "wallaby.terry.uga.edu", dbname="tesla", user="student", password="student") | |
# Querying the tesla database to fetch the latitude and longitude of the locations in Norway # | |
d <- dbGetQuery(conn,"SELECT y(location) AS lon, x(location) AS lat FROM superchargers WHERE country = 'Norway'") | |
# Printing the lat/long data on console # | |
d | |
# Involking Google Maps API for fetching the map # | |
map <- get_googlemap('Norway',marker=d,zoom=4) | |
# Setting configuration parameters for this map # | |
ggmap(map) + labs(x = 'Longitude', y = 'Latitude') + ggtitle('Norway Charging Stations') | |
# End # |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment