Open lorenzwalthert opened 6 years ago
I have recently tried to make use of this fix to make publication-quality maps which are not square-shaped. The fix does not actually allow for the user to select most possible image sizes in that most (but not all) image sizes re-introduce the "noisy image" issue (as in issue #17). For instance, I am able to get this to produce a nice, intelligible map (test1.pdf):
map_center <- c(lon=7.054235, lat=11.514064)
test <- get_googlemap(center=map_center, zoom=4, size=c(640,320))
ggmap(test)
But a "noisy" map (test2.pdf) is produced again if size
is replaced with any number of other vectors. I am having trouble figuring out a generalization that makes both 640, 320
(used in this post) and 420, 360
(as in the first post in this issue) work with this fix, but where a value like 720, 360
always produces a "noisy" map.
map_center <- c(lon=7.054235, lat=11.514064)
test <- get_googlemap(center=map_center, zoom=4, size=c(642,321))
ggmap(test)
A warning is issued if the dimensions aren't multiples of each other, e.g. size=c(2n,n)
. For instance, if size
is set to c(641,320)
(test3.pdf):
Warning message:
In matrix(map, nrow = scale * size[2], ncol = scale * size[1]) :
data length [819200] is not a sub-multiple or multiple of the number of columns [1282]
But if they are, no warning is issued, and the map is still "noisy", as in test2.pdf where size=c(642,321)
.
No idea how to solve that quickly. You could also try an alternative approach with https://github.com/paleolimbot/ggspatial.
This command
run from the
tidyup
branch, produces a noisy picture, essentially the same as https://github.com/dkahle/ggmap/issues/17. I fixed it in my branch essentially the same way as it was fixed in #17: https://github.com/lorenzwalthert/ggmap/commit/c6b68ebbb02929b4d628410bfbd0fdff32ac3152However, this was quick and dirty, maybe this had unexpected side effects.