Using ggmap with local file

I spent the afternoon trying to figure out a workflow for ggmap as an alternative to arcGIS for my team.

I continued to be hung up on the get_map command. Google needs an authorization, and when I try to use "osm", I get the following error:

> get_map("portland, oregon", source = "osm")
Error in download.file(url, destfile = tmp, quiet = !messaging, mode = "wb") : 
  cannot open URL 'http://maps.googleapis.com/maps/api/staticmap?center=portland,+oregon&zoom=10&size=640x640&scale=2&maptype=terrain&sensor=false'
In addition: Warning message:
In download.file(url, destfile = tmp, quiet = !messaging, mode = "wb") :
  cannot open URL 'http://maps.googleapis.com/maps/api/staticmap?center=portland,+oregon&zoom=10&size=640x640&scale=2&maptype=terrain&sensor=false': HTTP status was '403 Forbidden'

I also work in Julia and saw the package OpenStreetMapXPlot. This package allows you to use an existing .osm file that is saved locally to make a plot. It works immediately as intended.

Is there a way to use a local .osm file to get the right kind of object returned from get_map() calls? Such a feature would be very useful. Let me know if this question is too niche and if I should post at the git repo.

EDIT: I have a slightly different error message, based off of this issue I am now able to ping the osm database, but still get an error about access.

> portland_bb = getbb("portland, oregon")
> get_openstreetmap(bbox = portland_bb)
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=-122.8367489,45.432536,-122.4720252,45.6528812&scale=606250&format=png': HTTP status was '400 Bad Request'

Just to discard, are you using the development version?

install_github("dkahle/ggmap", ref = "tidyup")

Have you tried with a smaller bbox? sometimes retrieving a to large area gives this error.

I am not using the development version, should I be?

It looks like get_map no longer supports osm here.

Unfortunately I also get an error with stamen

> bb = c(left =  -76, lower = 5, right = -74, upper = 6)
> get_stamenmap(bb)
Error in get_stamenmap_tile(maptype, zoom, v[1], v[2], force = force,  : 
  is.wholenumber(x) || !(0 <= x && x < 2^zoom) is not TRUE

I think you should give the development version a try, because apparently the CRAN version is outdated.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.