Error grabbing OSM with ggmap and R

371 Views Asked by At

I have a loop (it is pretty long code, I will spare you) that reads a set of geographic coordinates from data and then uses them to download an OpenStreetMap: the line achieving this is as follows:

  newmap2<-get_openstreetmap(bbox = c(left = bbleft, bottom = bbbottom, right = bbright, top = bbtop),scale=80000)

the loop is supposed to run 82 times, as that is the number of different coordinates sets I have. After a variable number of cycles, (4 to 10) I get the following error:

Error: map grabbing failed - see details in ?get_openstreetmap.

I suppose this is due to temporary unavailability of the server. Is there a way to stop and repeat the request until a successful download occurs, rather than the code aborting?

0

There are 0 best solutions below