Ggmap: gives an error when using an open street map as a source

I am new to R and I follow this article to learn ggmap.

qmap("Forbidden city",zoom=15) qmap("Forbidden city",zoom=15, source="osm") 

While the first command above works fine, the second gives me error information:

Map with URL: http://maps.googleapis.com/maps/api/staticmap?center=Forbidden+city& zoom = 15 & size =% 20640x640 & maptype = terrain & sensor = false Terms of Use of the Google Maps API: http: / /developers.google.com/maps/terms Information from the URL: http://maps.googleapis.com/maps/api/geocode/json?address=Forbidden+city&sensor=false Google Maps API Terms of Service: http: // developers .google.com / maps / terms Error: Card capture failed - see details in? Get_openstreetmap. Additionally: Warning message: In the file download.file (url, destfile = destfile, quiet =! Messaging, mode = "wb"): cannot open: HTTP status was "503 Service Unavailable"

Any help is appreciated.

+8
r openstreetmap ggmap
source share
1 answer

I get the same error reproducibly.

I think this is due to the zoom=... specification. This argument is interpreted differently depending on the source . When you specify source="osm" , the call will be redirected to get_openstreetmap(...) . According to the documentation for this function:

... if you get an error when loading openstreetmap, an error is due to an incorrect scale specification ...

The zoom parameter affects the specification of the scale if scale="auto" (default). So basically, if zoom too large, the call will throw an error. I get errors with an increase> 13 for the Forbidden City, but this works:

 qmap("Forbidden city",zoom=13, source="osm") 
+1
source share

All Articles