使用ggmap获取卫星地图时遇到麻烦

时间:2019-06-25 20:00:41

标签: r ggplot2 ggmap

建议使用here的代码来下载和绘制带有ggmap的Google地图,对我而言是有效的。

newmap4 <- get_map(location = c(-71.2612362452596,42.3308503846824
                            ,-71.0475647202879,42.4560226746649), source = 'google')

 p <- ggmap(newmap4)
 p

但是,我真的很希望能够绘制卫星地图,而不是地形图。我尝试如下。

newmap5 <- get_map(location = c(-71.2612362452596,42.3308503846824
                            ,-71.0475647202879,42.4560226746649), source = 'google',
               maptype = "satellite")

 p <- ggmap(newmap5)
 p

在这种情况下,R打印的地图看起来与上面的newmap 4示例相同。有什么建议吗?

 Sys.info()
 sysname 
                                      "Linux" 
                                      release 
                             "4.4.0-1083-aws" 
                                      version   "#93-Ubuntu SMP Wed May 8 16:08:41 UTC 2019" 
                                     nodename  "application-997622-deployment-3251181-722tz" 
                                      machine 
                                     "x86_64" 
                                        login 
                                    "unknown" 
                                         user 
                               "rstudio-user" 
                               effective_user 
                               "rstudio-user"

1 个答案:

答案 0 :(得分:0)

使用get_googlemap()而不是get_map()尝试相同的代码。我不确定为什么要这样做,因为您指定的来源是Google。您已经注册了Google API密钥吗?

register_google(key = "<your key here>")
newmap5 <- get_googlemap(location = c(-71.2612362452596,42.3308503846824
                            ,-71.0475647202879,42.4560226746649), source = 'google',
               maptype = "satellite")
ggmap(newmap5)

map