R ggmap: Why can I create rectangular maps using the filename attribute, but not use them in a plot?

荒凉一梦 提交于 2019-12-23 08:37:20

问题


I would like to create a world map in R. I'm somewhat familiar with ggmap, so I tried something like this:

ggmap(get_googlemap(center=c(83,25),
                    zoom=1, scale=4, filename="world", size=c(640,300)))

It does work fine as far as the world.png is concerned.

I was actually quite happy to have found a workaround for ggmap's "can't show anything above 80° latitude" issue, due to which it's more or less impossible to create maps of the whole world.

However, in R itself, that is in the plots, the map looks not at all the way it's supposed to:

This only happens when the map is rectangular (when the size attribute is set accordingly), and not square (as would be the default).

Why's that? Is there any chance that this issue will be resolved in the future? And what's the quickest way from here to a proper world map?


回答1:


Use a scale limit.

Normal map

ggmap(get_map(location=c(28.978359,41.008240), zoom=13, scale="auto"))

Rectangular (cropped) map

ggmap(get_map(location=c(28.978359,41.008240), zoom=13, scale="auto")) +
    scale_x_continuous(limits = c(28.925,29.025), expand = c(0, 0)) +
    scale_y_continuous(limits = c(40.99,41.03), expand = c(0, 0))



来源:https://stackoverflow.com/questions/19438316/r-ggmap-why-can-i-create-rectangular-maps-using-the-filename-attribute-but-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!