library(ggplot2)
library(ggmap)
## Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
## Please cite ggmap if you use it! See citation("ggmap") for details.
#recuerde incorporar la linea "register_code" con su API KEY dada por su proveedor de mapas (si aplica)
#ej: register_google('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
caliCoord = geocode("Cali, colombia")
## Source : https://maps.googleapis.com/maps/api/geocode/json?address=Cali,+colombia&key=xxx
lidoCoord = c(-76.54835, 3.418902)
location = get_map(lidoCoord, zoom=15, maptype = "watercolor")
## maptype = "watercolor" is only available with source = "stamen".
## resetting to source = "stamen"...
## Source : https://maps.googleapis.com/maps/api/staticmap?center=3.418902,-76.54835&zoom=15&size=640x640&scale=2&maptype=terrain&key=xxx
## Source : http://tile.stamen.com/watercolor/15/9415/16071.jpg
## Source : http://tile.stamen.com/watercolor/15/9416/16071.jpg
## Source : http://tile.stamen.com/watercolor/15/9417/16071.jpg
## Source : http://tile.stamen.com/watercolor/15/9415/16072.jpg
## Source : http://tile.stamen.com/watercolor/15/9416/16072.jpg
## Source : http://tile.stamen.com/watercolor/15/9417/16072.jpg
## Source : http://tile.stamen.com/watercolor/15/9415/16073.jpg
## Source : http://tile.stamen.com/watercolor/15/9416/16073.jpg
## Source : http://tile.stamen.com/watercolor/15/9417/16073.jpg
#create canvas
plot = ggmap(location)
#display
plot

#Añadiendo estaciones y paradas del MIO
mio_stops <- read.delim("D:/MAIN/1erSemestre/Visualizacion/Taller5/MIO_STOPS.txt")
plot_estaciones = plot + geom_point(data=mio_stops, aes(x=DECIMALLONGITUDE,y=DECIMALLATITUDE),color=as.factor(mio_stops$TYPE_BUS))
plot_estaciones

#Añadiendo nombres de las estaciones y paradas
plot_estaciones_label = plot_estaciones + geom_text(data=mio_stops, aes(x=DECIMALLONGITUDE,y=DECIMALLATITUDE), label=mio_stops$SHORTNAME)
plot_estaciones_label

#Añadiendo curvas de densidad
plot_estaciones_label_densidad = plot_estaciones + geom_density2d()
plot_estaciones_label_densidad
