问题
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