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
I recently got the same error and it boiled down to ggmap not liking latitudes outside $\pm$ 80°.
However, I had to download my image separately as it was too large for a download (with OSM); this is not your problem, but I record it for future readers.
Here's how I solved it:
cbind
. Just make sure you know the longitude of your cut.Here's what I do:
require ("ggmap")
library ("png")
zoom <- 2
map <- readPNG (sprintf ("mapquest-world-%i.png", zoom))
map <- as.raster(apply(map, 2, rgb))
# cut map to what I really need
pxymin <- LonLat2XY (-180,73,zoom+8)$Y # zoom + 8 gives pixels in the big map
pxymax <- LonLat2XY (180,-60,zoom+8)$Y # this may or may not work with google
# zoom values
map <- map [pxymin : pxymax,]
# set bounding box
attr(map, "bb") <- data.frame (ll.lat = XY2LonLat (0, pxymax + 1, zoom+8)$lat,
ll.lon = -180,
ur.lat = round (XY2LonLat (0, pxymin, zoom+8)$lat),
ur.lon = 180)
class(map) <- c("ggmap", "raster")
ggmap (map) +
geom_point (data = data.frame (lat = runif (10, min = -60 , max = 73),
lon = runif (10, min = -180, max = 180)))
result:
Edit: I played a bit around with your google map, but I didn't get the latitudes correct. :-(