5

In my current R project I'm using the ggmap package to download and display maps. What bothers me is that you need internet access to load maps from google etc. I'd like to load a map from the internet and save it so I can work offline as well. An ideal solution should minimize the amount of code between get_map() (or a related command) and using the saved map within ggmap() (or a related command).

I know already that get_map() has a filename attribute to save maps as an image, and I also know the ggimage() method (I've never actually worked with it, though.) Is there a simple way save such a map, or are these two the best tools I have, and if so, how do you use them effectively?

1 Answer 1

3

Did you save the corresponding R object as well? E.g.:

# Download and save map image and R object
library(ggmap)
egy.map <- get_map(location=c(lon=30, lat=26), zoom=6, maptype="terrain", filename="~/Desktop/ggmapTemp")
save(egy.map, file="~/Desktop/egy-map.rda")

# Restart R or RStudio before running the code below
library(ggmap)
load("~/Desktop/egy-map.rda")
ls()
ggmap(egy.map)

This should let you download and save maps for later offline use, although maybe I misunderstood your question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.