[R] Creating World Map with Points

Lorenzo Isella lorenzo.isella at gmail.com
Mon Sep 28 21:07:48 CEST 2015


Dear All,
Please have a look at the snippet at the end of the email.
Essentially, I am trying to combine google maps with ggplot2.
The idea is to simply plot some points, whose size depend on a scalar,
on a google map.
My question is how I can extend the map in the snippet below in order
to plot the whole world.
Even at the lowest allowed zoom (=2), there are some continents left
out.
I cannot believe there is not a workaround for this while using the
google maps, but so far I have not made any progress at all.
Any suggestion is welcome.
Cheers

Lorenzo


##############################################################
library(ggmap)
map <- get_map(location = 'India', zoom = 2)

n <- 1000

set.seed(1234)

long <- runif(n,-180, 180)

lat <- runif(n,-90, 90)

size <- runif(n, 1,5)

data <- cbind(long, lat, size)

data <- as.data.frame(data)

gpl <- ggmap(map) +
geom_point(data = data,aes(x = long, y = lat),size=data$size,  alpha
=1, color="blue",show.legend  = F)


ggsave("test-map.pdf", gpl,width=10,height=10)



More information about the R-help mailing list