nota: como cobra google https://cloud.google.com/maps-platform/pricing.
apikey <- "AIzaSyBPxhDW9_bUJ1juxXEGvY_QcNIZNJPUy7A"
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.0.4
library(ggmap)
## Warning: package 'ggmap' was built under R version 4.0.5
## Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
## Please cite ggmap if you use it! See citation("ggmap") for details.
register_google(apikey)
qmap(c(-76.53871200303603,3.3739973437529476), zoom=12, maptype="hybrid")
## Source : https://maps.googleapis.com/maps/api/staticmap?center=3.373997,-76.538712&zoom=12&size=640x640&scale=2&maptype=hybrid&language=en-EN&key=xxx
paradaMIO <- read.delim("D:/curso analisis/mapa/MIO_STOPS.txt")
k <- 7
nIter <- 100
grupos <- kmeans(paradaMIO[,c(7,8)], k , iter.max = nIter, nstart = 1)
paradaMIO$grupos <- grupos$cluster
# poligono
#cluster <- subset(paradaMIO, paradaMIO$grupos)
#indicesC1 <- chull(paradaMIO$grupos==1)
#poligono <- paradaMIO[indicesC1,]
#mapa <- ggplot(paradaMIO, aes(DECIMALLONGITUDE, DECIMALLATITUDE, color=TYPE_BUS))
city <- get_map(c(-76.5, 3.43),zoom=12)
## Source : https://maps.googleapis.com/maps/api/staticmap?center=3.43,-76.5&zoom=12&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx
mapa <- ggmap(city)
mapa <- mapa + geom_point(data=paradaMIO, aes(x=DECIMALLONGITUDE, y=DECIMALLATITUDE), color=paradaMIO$grupos, size=paradaMIO$PASSANGERS_NUM * 0.020)
mapa