World map with ggmap

后端 未结 4 1858
無奈伤痛
無奈伤痛 2020-11-29 03:43

I am using ggmap and wish to have a map of the world centered on Australia to which I can easily plot geocoded points. ggmap seems to be a lot easier to use compared to some

4条回答
  •  遥遥无期
    2020-11-29 04:15

    I have managed to build world map based on Google Maps. This is unfortunately slightly distorted, as I believe ggmap/Google Maps imposes restrictions (data length = 409600 pixels, with dimension being a multiple of 792). Nevertheless, the following combination of size, scale and zoom parameters delivers Google world map with ggmap.

    Natrally, you can alter lon to change the point of longitudal focus to Australia, as you wish.

    library(tidyverse)
    
    your_gmaps_API_key <- ""
    
    get_googlemap(center = c(lon = 0, lat = 0)
              , zoom = 1
              , maptype="roadmap"
              , size = c(512,396) 
              , scale = 2
              , color = "bw"
              , key = your_gmaps_API_key) %>% ggmap(.)
    

    Note: points on the map are from my own dataset and not produced by the code above, but the world map is of core importance here.

提交回复
热议问题