ggmap icon indicating copy to clipboard operation
ggmap copied to clipboard

get_map cannot load OpenStreetMap

Open weianuk opened this issue 7 years ago • 6 comments

Tried to use get_map to load openstreetmap, but it gives the error below:

map <- get_map(location = 'uk', zoom = 8, source = "osm")

Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=uk&zoom=8&size=640x640&scale=2&maptype=terrain&sensor=false Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=uk&sensor=false Error: map grabbing failed - see details in ?get_openstreetmap. In addition: Warning message: In download.file(url, destfile = destfile, quiet = !messaging, mode = "wb") : cannot open URL 'http://tile.openstreetmap.org/cgi-bin/export?bbox=-5.19103891796874,54.3650719770938,-1.67541391796874,56.3626958621291&scale=2800000&format=png': HTTP status was '400 Bad Request'

@dkahle Is there any effective solution to this problem? thanks.

weianuk avatar Aug 15 '17 01:08 weianuk

See this issue: https://github.com/dkahle/ggmap/issues/117

From that issue, it seems that OpenStreetMap has blocked external applications (such as ggmap) from calling its export API function because of the load this puts on the OSM servers.

The fix is to use another map source, such as stamen.

jonathan-g avatar Aug 24 '17 17:08 jonathan-g

It seems this package: https://github.com/ifellows/ROSM/blob/master/OpenStreetMap/R/osm.R https://cran.r-project.org/web/packages/OpenStreetMap/OpenStreetMap.pdf is able to get OSM tiles... Isn't there a way to fix ggmap using the same approach?

Edouard-Legoupil avatar Jan 10 '18 23:01 Edouard-Legoupil

Looks like we need to fix the API access:

https://wiki.openstreetmap.org/wiki/Downloading_data

scottmmjackson avatar Feb 09 '18 22:02 scottmmjackson

Any news on this? It would be really helpful if this functionality was restored.

competulix avatar Mar 07 '18 15:03 competulix

To clarify the comment from @Edouard-Legoupil it looks like the package "OpenStreetMap" breaks a bounding box into individual tiles and gets them one at a time, then combines into one map. Not sure if that's what get_openstreetmap is also doing

As FYI, here is a link to some blog posts by the OpenStreetMap package author, Ian Fellows - http://blog.fellstat.com/?cat=15

bbrewington avatar Mar 26 '18 20:03 bbrewington

Most of the things needed to make get_openstreetmaps (or any other tile server) work are already present in get_stamenmap.

I have created new functions for getting tiles from arbitrary tile servers (get_tilemap), and some prespecified tile servers. Not all of the features of the old function are available yet, as I am currently busy with my thesis. Also, I am not sure if I need to do something to make this okay with the usage policies, I will look into that at a later point.

In case anyone is interested: https://github.com/lysogeny/ggmap

Here is a map I just made: opentopomap

lysogeny avatar Jan 27 '19 15:01 lysogeny