Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_map ignores the source argument #51

Closed
grialex opened this issue Feb 11, 2015 · 90 comments
Closed

get_map ignores the source argument #51

grialex opened this issue Feb 11, 2015 · 90 comments

Comments

@grialex
Copy link

grialex commented Feb 11, 2015

I am trying to grab a map like this:

get_map(location = c(6.815375, 51.217942), zoom = 11, source = "osm")

Following error occures:

Error in download.file(url, destfile = destfile, quiet = !messaging, mode = "wb") :
can't open URL 'http://maps.googleapis.com/maps/api/staticmap?center=51.217942,6.815375&zoom=11&size=%20640x640&maptype=terrain&sensor=false'

And an additional warning:

W
In download.file(url, destfile = destfile, quiet = !messaging, mode = "wb") :
cannot open: HTTP status was '403 Forbidden'

Why does ggmap query google, although source is set to "osm" ? And why is the status 403 forbidden?

@jtdoud
Copy link

jtdoud commented Feb 24, 2015

I also have similar issues:

base <- get_map(location = center, zoom= 10, source = "stamen", maptype = "watercolor")

Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=49.22741,-122.8735&zoom=10&size=%20640x640&maptype=terrain&sensor=false
Google Maps API Terms of Service : http://developers.google.com/maps/terms
Error in readPNG(destfile) : file is not in PNG format

@dkahle
Copy link
Owner

dkahle commented Feb 24, 2015

the first problem looks like an internet error, sometimes the stamen servers are down/don't respond, and you get that 403 error. the second is actually due to the current cran version, just do the below and rerun:

library(devtools)
install_github("dkahle/ggmap")
library(ggmap)

@dkahle dkahle closed this as completed Feb 24, 2015
@dkahle
Copy link
Owner

dkahle commented Feb 24, 2015

oh, and for why ggmap queries google for osm: it needs to get the spatial coordinates of the query.

@deltoroi
Copy link

deltoroi commented Jul 23, 2018

Getting a similar error with get_map, Im unable to find any supporting info. This code worked well just a month ago:
My code:

atw<- get_map(location=c(-88.68,42.14), zoom=10, scale=2)
atw<-ggmap(atw)

Error:

  cannot open URL 'https://maps.googleapis.com/maps/api/staticmap?center=texas&zoom=6&size=640x640&scale=2&maptype=terrain&language=en-EN&key=AIzaSyB8GaTLxSuCRsFE55WZ0O4q63fzy9NhFDs'```

@samistat08
Copy link

samistat08 commented Sep 12, 2018

Same problem here today. Is there any solution to this? I am using "google" as source. The code worked till yesterday!

@dkahle
Copy link
Owner

dkahle commented Sep 12, 2018

Have you tried installing the GitHub version of ggmap? The CRAN version is quite old...

@ZachNikolakis
Copy link

I experienced the same thing. My code worked two weeks ago but now I get the same error as above. I also installed the GitHub version of ggmap.

@dkahle
Copy link
Owner

dkahle commented Sep 19, 2018

Sorry about that. Try installing from the tidyup branch on GitHub and check back in.

@statshermit
Copy link

same problem here and I have a public presentation tomorrow :(
My code was working fine until yesterday and I am using the latest GitHub version of ggmap. What do you mean by "Try installing from the tidyup branch on GitHub"? I search for tidyup github dkahle but find nothing. Help?

@statshermit
Copy link

statshermit commented Sep 19, 2018

My API is registered using register_google (key=.....) and it is showing fine with ggmap_credentials().

Here is my error message:

Error in download.file(url, destfile = destfile, quiet = !messaging, mode = "wb") :
cannot open URL 'https://maps.googleapis.com/maps/api/staticmap?center=-44.395,171.23&zoom=12&size=640x640&scale=2&maptype=terrain&language=en-EN&key=A...g_'
In addition: Warning message:
In download.file(url, destfile = destfile, quiet = !messaging, mode = "wb") :
cannot open URL 'https://maps.googleapis.com/maps/api/staticmap?center=-44.395,171.23&zoom=12&size=640x640&scale=2&maptype=terrain&language=en-EN&key=A...g_
': HTTP status was '403 Forbidden'

@dkahle
Copy link
Owner

dkahle commented Sep 19, 2018

This works just fine for me:

if(!requireNamespace("devtools")) install.packages("devtools")
devtools::install_github("dkahle/ggmap", ref = "tidyup")
ggmap(get_googlemap())
register_google(key = "my_google_key_here")
geocode("waco texas")

@statshermit
Copy link

It works!!!! THANK YOU so much dkahle

I ran your code above and still got similar error message but once I restart R it works. A big sight of relieve here. Thank you. Appreciate your prompt help here

@dkahle
Copy link
Owner

dkahle commented Sep 19, 2018

Happy to help. With the accumulated changes in ggplot2 and elsewhere, ggmap (badly) needs to be updated on CRAN. I hope to do that soon. Until then, you can install from the GitHub repo (branch tidyup) as I showed above, and everything should work fine for you and your audience. I'm sure folks will let me know if that's not the case. :)

@HovhannesSahakyan
Copy link

Hello dkahle,

Can't get the map. Can you please help?

Error in download.file(url, destfile = destfile, quiet = !messaging, mode = "wb") :
cannot open URL 'https://maps.googleapis.com/maps/api/staticmap?center=Kazakhstan&zoom=3&size=640x640&scale=2&maptype=terrain&style=feature:administrative.country%7Celement:labels%7Cvisibility:off&key=65492'
In addition: Warning message:
In download.file(url, destfile = destfile, quiet = !messaging, mode = "wb") :
cannot open URL 'https://maps.googleapis.com/maps/api/staticmap?center=Kazakhstan&zoom=3&size=640x640&scale=2&maptype=terrain&style=feature:administrative.country%7Celement:labels%7Cvisibility:off&key=65492': HTTP status was '403 Forbidden'

@statshermit
Copy link

dharle,

sorry to bother you again but I manage to get 8 hours of work today with ggmap after the fix this morning but by 4PM NZT it stops working. My API credential has to get registered again. I can call geocode but it won't allow me to use ggmap(get_googlemap()).

I have tried to run it from another location (home) in case it's my workplace's firewall or proxy issue but I still get the same problem. Help please?

The error message is as follows,

geocode("waco texas")

Source : https://maps.googleapis.com/maps/api/geocode/json?address=waco%20texas&key=AIzaSyAMV
lon lat
1 -97.14667 31.54933

ggmap(get_googlemap(center=c(lon=-97.14667,lat=31.54933)))

Error in download.file(url, destfile = destfile, quiet = !messaging, mode = "wb") :
cannot open URL 'https://maps.googleapis.com/maps/api/staticmap?center=31.54933,-97.14667&zoom=10&size=640x640&scale=2&maptype=terrain&key=AIzaSyAMV'
In addition: Warning message:
In download.file(url, destfile = destfile, quiet = !messaging, mode = "wb") :
cannot open URL 'https://maps.googleapis.com/maps/api/staticmap?center=31.54933,-97.14667&zoom=10&size=640x640&scale=2&maptype=terrain&key=AIzaSyAMV': HTTP status was '403 Forbidden'

@dkahle
Copy link
Owner

dkahle commented Sep 20, 2018

@HovhannesSahakyan – I don't know what code you entered to get the resulting error, but your message appears effectively identical to that of @statshermit below, so see the response there. Does a more basic call work? (That is, can you get a map from Google at all?)

@statshermit – Unfortunately I don't think I can help on this one since the server is rejecting your HTTP request. Since you're giving your API key, changing your (WAN-side) IP address won't matter – they can still identify you. Waiting a while and trying again may be your only real option?

@HovhannesSahakyan
Copy link

HovhannesSahakyan commented Sep 20, 2018 via email

@phd-project
Copy link

phd-project commented Sep 20, 2018

@statshermit (@dkahle)

I had the same error code. Here's what worked for me. Go to your google cloud console, and enable Google Maps Static API. It looks like Google's changed stuff recently, and that function requires enabling the map API, separate from, and in addition to, enabling the geocoding API. That could explain why geocoding works for you, while grabbing the map doesnt. Good luck

@statshermit
Copy link

@phd-project

You are right! I can call googlemap again. Thanks so much for sharing. I so appreciate everyone's help - thumbs up to everyone!

@jhongajardo
Copy link

oohhhh @phd-project thank you very much for sharing the solution to this problem.
I have again the googlemap on my graphics!

<))))°>

@emilydinh
Copy link

emilydinh commented Sep 28, 2018

Hi everyone,

I'm new to ggmap, so pardon me if I'm making ignorant beginner's mistakes. It seems I can't get anything from ggmap to work for me. Below, I show the errors I'm getting past using @dkahle 's code for installing from the tidyup GitHub branch. I've tried installing/re-installing both the CRAN and GitHub versions then restarting R several times already, and I get the same errors with the CRAN version.

ggmap(get_googlemap())

Error in download.file(url, destfile = destfile, quiet = !messaging, mode = "wb") :
cannot open URL 'https://maps.googleapis.com/maps/api/staticmap?center=29.763284,-95.363271&zoom=10&size=640x640&scale=2&maptype=terrain&key=...'
In addition: Warning message:
In download.file(url, destfile = destfile, quiet = !messaging, mode = "wb") :
cannot open URL 'https://maps.googleapis.com/maps/api/staticmap?center=29.763284,-95.363271&zoom=10&size=640x640&scale=2&maptype=terrain&key=...': HTTP status was '403 Forbidden'

register_google(key = "...")

geocode("waco texas")

Source : https://maps.googleapis.com/maps/api/geocode/json?address=waco%20texas&key=...
lon lat
1 NA NA
Warning message:
geocode failed with status OVER_QUERY_LIMIT, location = "waco texas" `

Then I test that my API is registered with ggmap_credentials. Seems fine, I think.

ggmap_credentials()

Google -
key : ...
account_type : standard
day_limit : 2500
second_limit : 50
client :
signature : `

Then I try get_map().

test1 <- get_map(location = "Texas")

Error in download.file(url, destfile = destfile, quiet = !messaging, mode = "wb") :
cannot open URL 'https://maps.googleapis.com/maps/api/staticmap?center=Texas&zoom=10&size=640x640&scale=2&maptype=terrain&language=en-EN&key=...'
In addition: Warning message:
In download.file(url, destfile = destfile, quiet = !messaging, mode = "wb") :
cannot open URL 'https://maps.googleapis.com/maps/api/staticmap?center=Texas&zoom=10&size=640x640&scale=2&maptype=terrain&language=en-EN&key=...': HTTP status was '403 Forbidden'

I checked whether I enabled the Google Maps Static & Geocoding APIs as @phd-project suggested, then tried the code above again. Yep they were enabled, but still no go. @HovhannesSahakyan mentioned needing a "real" key? What does that mean? Paying Google for a key and therefore paying to use ggmap?

I've been stuck on this for 2 days now, so I'm not sure what else to try. Please help!

@dkahle
Copy link
Owner

dkahle commented Sep 28, 2018

Hi @emilydinh – I just pushed some changes to get_googlemap(). Try this: re-install from GitHub with devtools::install_github("dkahle/ggmap", ref = "tidyup"), reboot R, load ggmap, load in your API key, then try ggmap(get_googlemap()). Does that work?

Note: be sure to clean your GitHub post of your private API key.

@jhongajardo
Copy link

Hi @emilydinh, please watch next link #51 (comment).
I Hope It is of your help..

@statshermit (@dkahle)

I had the same error code. Here's what worked for me. Go to your google cloud console, and enable Google Maps Static API. It looks like Google's changed stuff recently, and that function requires enabling the map API, separate from, and in addition to, enabling the geocoding API. That could explain why geocoding works for you, while grabbing the map doesnt. Good luck

@emilydinh
Copy link

emilydinh commented Sep 28, 2018

Hi @dkahle,

Ah, looks like I was too quick copying and pasting in my first post. Thanks! And your solution somewhat worked...? I haven't had anything show up in the plot area before, so this is progress!

get_googlemap

Then I tried get_map again just to see what would happen. I got a different error than last time: error in data.frame vs. error in download.file

get_map(location = "Texas")

Source : https://maps.googleapis.com/maps/api/staticmap?center=Texas&zoom=10&size=640x640&scale=2&maptype=terrain&language=en-EN&key=...
Source : https://maps.googleapis.com/maps/api/geocode/json?address=Texas&key=...
Error in data.frame(ll.lat = ll[1], ll.lon = ll[2], ur.lat = ur[1], ur.lon = ur[2]) :
arguments imply differing number of rows: 0, 1
In addition: Warning message:
geocode failed with status OVER_QUERY_LIMIT, location = "Texas"

Thanks for your quick response! Let me know what the next step is.

@emilydinh
Copy link

Hi @jhongajardo,

I said in my first post that I already tried @phd-project's solution. I just checked again that the APIs are enabled, and they are.

Thanks for your help!

@dkahle
Copy link
Owner

dkahle commented Sep 28, 2018

@emilydinh : Remember that the output contains your private API key. :)

When you copy/paste the URL into the browser, what happens?

@emilydinh
Copy link

@dkahle: Ah, you are right about the key in the output. Anyways, the URL sends me to a webpage version of the plot error.

image

@dkahle
Copy link
Owner

dkahle commented Sep 28, 2018

I just pushed minor things, try to get those, but I don't expect a change.

I previously got what Google's giving you when I wasn't supplying an API key, but I can't reproduce the problem now. I can't reproduce yours, either. Obviously, something is wrong with the API part - is it the URL ggmap is making? (maybe), is it a mistyped API key? (probably not), is it some other environmental assumption? I don't know. The geocode error is obvious, but I don't think that's causing the problem. What seems pretty clear: if you can load the URL in the browser, the R side stuff should work just fine.

To be clear, when, in a fresh R session, I load ggmap, register my Google API key with register_google(), and run ggmap(get_googlemap()), it works just fine.

@emilydinh
Copy link

Hi @dkahle, I don't think I've mistyped my API key because I copied and pasted it straight from Google. I've tried your solution with a new R session several times, but still get the same issues. Is there anything else I can do?

@dkahle
Copy link
Owner

dkahle commented Oct 13, 2018

@arne1921KF, @kambanane – I'm sorry for the frustration. To be clear: this was not a change in ggmap, but Google's web API. ggmap simply facilitates the connection between R and various Google services; it has no control over either.

@dvorw
Copy link

dvorw commented Oct 13, 2018 via email

@arne1921KF
Copy link

arne1921KF commented Oct 13, 2018 via email

@grafau
Copy link

grafau commented Oct 15, 2018

Hi!

So, I have done all of the above: enabled billing, static map api, geocoding api, got key, installed ggmap from 'tidy' branch.
I load library:

library(ggmap)
Loading required package: ggplot2
Google Maps API Terms of Service: http://developers.google.com/maps/terms.
Please cite ggmap if you use it: see citation('ggmap') for details.
Warning message:
package ‘ggplot2’ was built under R version 3.4.2

Now that is the kicker: whenever I try to register_google, I get following:
register_google(key)

Error in register_google(key) : could not find function "register_google"

And of course, when trying to get_map:

I get:

HTTP status was '403 Forbidden'

Any ideas? Many thanks!

Rafal

@dkahle
Copy link
Owner

dkahle commented Oct 15, 2018

@grafau : If register_google() isn't found, sounds like the install from GitHub didn't work. Or, it could be that it did, but you didn't restart R and reload the newer ggmap. I would just run by that again and make sure things are going as you expect. (And maybe update ggplot2?)

@dvorw
Copy link

dvorw commented Oct 16, 2018 via email

@simonberrebi
Copy link

Hey all,

This is a really cool tool, thanks to everyone who contributed! However, I'm having the same issue. I added my credit card info and register_google'ed. When I tried to get_map, I got the following error message:

Source : https://maps.googleapis.com/maps/api/staticmap?center=Europe&zoom=4&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx*
Error in get_googlemap(center = location, zoom = zoom, maptype = maptype, :
Forbidden (HTTP 403).

  • with the link pointing to a page saying: "The Google Maps Platform server rejected your request. This API project was not found. This API project may have been deleted."

Then I enabled APIs through Google API's library (Places API, MAP Static API, and Roads API). It still doesn't work but I get a different message with no 403 (see below). Could the issue be that were missing some APIs? If so, which ones should be enabled?

Source : https://maps.googleapis.com/maps/api/staticmap?center=42.14,-88.68&zoom=10&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx*
1280x1280 terrain map image from Google Maps. see ?ggmap to plot it.

@petersoapes
Copy link

Hi all
Following some of the suggestions on this chain I was able to get ggmap working again on my laptop (yay!). this is what I ran
if(!requireNamespace("devtools"))install.packages("devtools")
devtools::install_github("dkahle/ggmap", ref = "tidyup")
then I linked my billing enabled API key with register_google(), and it worked.

When I've tried to replicate this on my work computer, I can't get ggmaps to load. I get the following error when trying to run the dev::tools_install_github()

Loading required package: ggplot2
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
namespace ‘stringi’ 1.1.2 is being loaded, but >= 1.1.6 is required
Error: package or namespace load failed for ‘ggmap’

@dkahle
Copy link
Owner

dkahle commented Oct 18, 2018

Hi @petersoapes – looks like you need to update stringi:

install.packages("stringi")

Give that a shot and retry.

@petersoapes
Copy link

Thanks, that worked.
The second time I installed "stringi" and then did the rest of the steps, it worked. I think I may have not been resatrting my R session correctly.

@g-mann
Copy link

g-mann commented Oct 24, 2018

Super appreciative of all the help posted here (particularly @dkahle and @RomanAbashin)...THANKS!!!

I was having similar problems with a recurring 403 problem when trying to use get_map with source="google". I had installed the dkahle/ggmap from the tidyup branch and got the API key/billing sorted out with google. However, despite having enable both the Geocoding and Maps Static APIs, only the former was working (i.e., I was getting the "Waco, Texas" coordinates, but couldn't get a map). I noticed on the Google dashboard that the Geocoding API was getting some traffic (every time I tried it), but that the Maps Static API wasn't showing anything. I eventually regenerated the API key and it all worked. Just thought this might help someone else.

@sarahkaunitz
Copy link

Hi @dkahle
You seem very knowledgeable about retrieving and making all these google maps. I am trying to get a map in R and am getting this error.

sfmap <- qmap("San Francisco", zoom = 12, type = "roadmap")

cannot open URL 'http://maps.googleapis.com/maps/api/staticmap?center=San+Francisco&zoom=12&size=640x640&scale=2&maptype=terrain&language=en-EN&sensor=false': HTTP status was '403 Forbidden'Error in download.file(url, destfile = tmp, quiet = !messaging, mode = "wb") :
cannot open URL 'http://maps.googleapis.com/maps/api/staticmap?center=San+Francisco&zoom=12&size=640x640&scale=2&maptype=terrain&language=en-EN&sensor=false'

Do you think you could help me figure out what I need to do for it to work?
Thanks in advance!

@dkahle
Copy link
Owner

dkahle commented Nov 29, 2018

Hi @sarahkaunitz

After re-installing the dev version of ggmap (see above), and going on Google Cloud's manager and enabling the Maps Static and Geocoding APIs along with billing, try:

sfmap <- get_googlemap("san francisco", zoom = 12, type = "roadmap")
ggmap(sfmap)

@sabahzero
Copy link

Hi all,
I am trying everything for hours and nothing has worked, halp!
I have my Google API code and it shows as registered in R

I first tried
devtools::install_github("hadley/ggplot2")
devtools::install_github("dkahle/ggmap")

I then tried the suggested example
if(!requireNamespace("devtools")) install.packages("devtools")
devtools::install_github("dkahle/ggmap", ref = "tidyup")
ggmap(get_googlemap())
register_google(key = "keyhere")
geocode("waco texas")

Again and again and again the error keeps coming up as
"Error in get_googlemap() : Forbidden (HTTP 403)"
I've looked up how to get around this without luck.

All I want to do is plot lat and lon points corresponding to my dataset to a map in R
If it helps, here's a previous example code that was working in May but isn't anymore (because of the API, I suppose?): https://github.com/sabahzero/MicrobialEcology_AmpliconSeqWorkflow_UlHasanetal/tree/master/v1_May15-2018

Very very many thanks in advance 🙏

@ryansfuller
Copy link

ryansfuller commented Dec 5, 2018

Hello everyone.
I just wanted to give the problem I had and what I did to solve it for any newcomers to this ever growing feed. For me, I was getting the 'Forbidden (HTTP 403) error that many were having in an old code I used for a manuscript. I followed the solutions found in this comment overflow but more closely to @RomanAbashin's (Sept 30th) (Link here: #51 (comment)) nicely detailed summary comment as follows:
Note: It's imperative to do these in the proper steps -- I think that is why some are having issues with individual steps despite doing all that has been suggested! For me, it worked the first time.

Google Cloud Console (before doing anything in R):

  1. First I registered an API key within the Google Cloud console following the link provided from @RomanAbashin -- I did not restrict the API key as suggested by Google (does anyone have any advice on this moving forward? I'd like to make it as secure as possible -- but still have it usable). I also made sure billing was turned on as suggested in many other posts -- it's free unless you are using it to pull large quantities of maps, but they want a credit card to 'make sure you aren't a robot'.
  2. You will need to create a new project
  3. Next, search for and enable the 'Geocoding API' and the 'Maps Static API'
    From your Google Cloud Page Click 'APIs and Services' >> Library >> (To Filter: look in the left hand column under Category and scroll down to 'Maps' -- Click it >> Geocoding API should be in the first row (Enable It). (Repeat for 'Maps Static API', which is in the 3rd row)
  4. From the 'Credentials' menu you can Copy your API key to the clipboard.

Onward to R!

  1. I reinstalled ggmap using @dkahle code here: (Link: get_map ignores the source argument #51 (comment)) :
    devtools::install_github("dkahle/ggmap", ref = "tidyup")
  2. I rebooted R
  3. Loaded ggmap library (copy-paste API from Google Cloud Console):
    library(ggmap)
    register_google(key = 'copy-API-key-from-GoogleConsole')
  4. Run my code again. It works!

@sabahzero have you had any luck over the last few days?
From your code linked above on your github:
# Create zoomed-in map (main figure) Zoom=get_map(location=c(-116.9685,32.22644,-116.9241,32.26755), maptype="roadmap")
Sidenote: I didn't change my command for 'get_map()' as suggested in some other posts and it still works for me. I think if you can do all that is required for the API steps and register it, reinstall ggmap with the above command, reboot R, load ggmap, register your API key, and rerun your code you should have success!

Try following my steps listed above or visit @RomanAbashin's comment that I linked to. He has a link to Google's page with info about properly setting up your API with billing and all.

After writing this, I dug through the comments more and I see much of this is also summarized here:
(#51 (comment)).

Thanks much to @dkahle & @RomanAbashin! Plus many others who have been troubleshooting! You made this one easy for me to fix with manuscript reviews due in a couple of days!

@dvorw
Copy link

dvorw commented Dec 5, 2018 via email

@lgellis
Copy link

lgellis commented Dec 10, 2018

For those who it might help, I updated my ggmap tutorial to include the google cloud platform steps with screenshots to create the service, get an api key and apply it. https://www.littlemissdata.com/blog/maps

@dkahle thank you so much for your awesome package and all the support you've been giving. @full6186 great summary above.

@CaperKen
Copy link

The little miss data tutorial, followed the code religiously and it worked very well until I got to 9a.

(Thanks Little Miss. Really very well done.)

At Map 9a, I started getting the "403" error and that has not stopped with many re-attempts. Now, none of the map code works.

I've followed all the suggestions above, including re-installing, rebooting, using my API, etc. Still "403".

Any help would be great.

@atenaeslami
Copy link

atenaeslami commented Jan 27, 2019

@RomanAbashin, @dkahle
I am a new user to R package. It is really necessary for me to learn making maps using ggmap package, but unfortunately, i spent lots of time on it without any result.
I did every solution @dkahle suggested, but API problem arosen!
Thus, i used @RomanAbashin recommendationas follow:
library(ggmap)
Loading required package: ggplot2
Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
Please cite ggmap if you use it! See citation("ggmap") for details.
library(tmaptools)
ggmap(get_stamenmap(rbind(as.numeric(paste(geocode_OSM("Vienna")$bbox))), zoom = 11))))
Error: unexpected ')' in "ggmap(get_stamenmap(rbind(as.numeric(paste(geocode_OSM("Vienna")$bbox))), zoom = 11)))"
ggmap(get_stamenmap(rbind(as.numeric(paste(geocode_OSM("Vienna")$bbox))), zoom = 11))))
Error: unexpected ')' in "ggmap(get_stamenmap(rbind(as.numeric(paste(geocode_OSM("Vienna")$bbox))), zoom = 11)))"

but i have problem again,

I will really appreciate you if you can help me.

@dkahle
Copy link
Owner

dkahle commented Jan 28, 2019

Hi @atenaeslami

I've been working on ggmap quite a bit recently. Please re-install using: devtools::install_github("dkahle/ggmap") (no tidyup). After that, re-start R and reload ggmap. Then, try something simple, like:

bbox <- c(left = -97.1268, bottom = 31.536245, right = -97.099334, top = 31.559652)
ggmap(get_stamenmap(bbox, zoom = 13))

That should work regardless of Google stuff. Does it? If not, please report your input and output.

To test whether your Google setup is working properly, I suggest two things. First, use google_key() to check if you have an API key. If you get NA, it won't work, and you'll need to use register_google() to register your key; see the main GitHub page for details. Once you've registered it, try something like geocode("the white house"). It should be clear if it's working properly or not from that point. If not, let me know with input/output. Thanks!

@atenaeslami
Copy link

@dkahle
YES, i finally get the map. thank you very much.

devtools::install_github("dkahle/ggmap")
Downloading GitHub repo dkahle/ggmap@master
WARNING: Rtools is required to build R packages, but is not currently installed.

Please download and install Rtools 3.5 from http://cran.r-project.org/bin/windows/Rtools/.

checking for file 'C:\Users\negin\AppData\Local\Temp\RtmpAxw6BI\remotesce4708ee17\dkahle-ggmap-e55c0b2/DESCRIPTION' ...

checking for file 'C:\Users\negin\AppData\Local\Temp\RtmpAxw6BI\remotesce4708ee17\dkahle-ggmap-e55c0b2/DESCRIPTION' ...

√ checking for file 'C:\Users\negin\AppData\Local\Temp\RtmpAxw6BI\remotesce4708ee17\dkahle-ggmap-e55c0b2/DESCRIPTION' (1.1s)

  • preparing 'ggmap': (1.1s)

    checking DESCRIPTION meta-information ...

    checking DESCRIPTION meta-information ...

√ checking DESCRIPTION meta-information

  • checking for LF line-endings in source and make files and shell scripts (890ms)

  • checking for empty or unneeded directories

    Removed empty directory 'ggmap/.github'

  • looking to see if a 'data/datalist' file should be added

  • building 'ggmap_3.0.0.tar.gz' (2.7s)

  • installing source package 'ggmap' ...
    ** R
    ** data
    *** moving datasets to lazyload DB
    ** inst
    ** byte-compile and prepare package for lazy loading
    ** help
    *** installing help indices
    converting help for package 'ggmap'
    finding HTML links ... done
    LonLat2XY html
    OSM_scale_lookup html
    XY2LonLat html
    bb2bbox html
    calc_zoom html
    crime html
    file_drawer html
    geocode html
    geom_leg html
    finding level-2 HTML links ... done

    get_cloudmademap html
    get_googlemap html
    get_map html
    get_navermap html
    get_openstreetmap html
    get_stamenmap html
    ggimage html
    gglocator html
    ggmap-defunct html
    ggmap html
    ggmap_options html
    ggmapplot html
    hadley html
    inset html
    inset_raster html
    legs2route html
    make_bbox html
    mapdist html
    print.ggmap html
    qmap html
    qmplot html
    reexports html
    Rd warning: C:/Users/negin/AppData/Local/Temp/RtmpcRWPBt/R.INSTALL16b46a7d5ca1/ggmap/man/reexports.Rd:14: file link '%>%' in package 'magrittr' does not exist and so has been treated as a topic
    register_google html
    revgeocode html
    route html
    theme_inset html
    theme_nothing html
    trek html
    wind html
    zips html
    ** building package indices
    ** testing if installed package can be loaded

  • DONE (ggmap)
    In R CMD INSTALL
    Warning messages:
    1: In untar2(tarfile, files, list, exdir) :
    skipping pax global extended headers
    2: In untar2(tarfile, files, list, exdir) :
    skipping pax global extended headers

library(ggmap)
Loading required package: ggplot2
Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
Please cite ggmap if you use it! See citation("ggmap") for details.
bbox <- c(left = -97.1268, bottom = 31.536245, right = -97.099334, top = 31.559652)
ggmap(get_stamenmap(bbox, zoom = 13))
Source : http://tile.stamen.com/terrain/13/1885/3338.png
Source : http://tile.stamen.com/terrain/13/1886/3338.png
Source : http://tile.stamen.com/terrain/13/1885/3339.png
Source : http://tile.stamen.com/terrain/13/1886/3339.png

I need the Iran and Turkey maps near together. How i must order it?

Would you please tell me how?

Kind Regards

@jncai
Copy link

jncai commented Feb 3, 2019

When I use
library(devtools)
install_github("dkahle/ggmap")

it appears that
Downloading GitHub repo dkahle/ggmap@master
Error in utils::download.file(url, path, method = download_method(), quiet = quiet, :
cannot open URL 'https://api.github.com/repos/dkahle/ggmap/tarball/master'

How can I deal with this problem?

Thanks

@dkahle
Copy link
Owner

dkahle commented Feb 3, 2019

Hi @atenaeslami – I'm not familiar with that warning on the install; I'd just suggest some Google searching. Looks like you're getting tiles from Stamen; you probably just need the proper bounding box, no?

@jncai – Thanks for the post/email. That doesn't appear to be a ggmap problem: for some reason, you aren't able to get what you need from GitHub. Ordinarily I associate that error with you not being online, but I'm assuming you covered that base already (obviously you were online at the time of this post). Can you download any file off the internet from within R?

@sabahzero
Copy link

Just wanted to update the additions to the read.me and comments here resolved all my troubles, thank you!

@atenaeslami
Copy link

Hi @dkahle
yes, you are correct, but unfortunately, I did not find the right bounding box.
Who can help me? I want to learn a general rule to find the bounding box for any map in the world.

@atenaeslami
Copy link

atenaeslami commented Mar 6, 2019 via email

@rrmn
Copy link

rrmn commented Mar 6, 2019 via email

@atenaeslami
Copy link

atenaeslami commented Mar 6, 2019 via email

@lgellis
Copy link

lgellis commented Aug 29, 2019

@CaperKen - I think the issue is that while you might have added a credit card, your API key is associated with a project that does not have billing set up. I had the same thing happen and it was fixed when I added billing to the project.

You can test if this is your issue by running the code up to 9a. The next day try to run from 9a on, it should work. You may have to reload the data and the libraries.

From what I can tell they allow one api call daily for accounts without active billing set up. All the code up to 9a is using one base googlemap graph (p). It then has to update in 9a, 9b, 10a, 10b b/c we are modifying the graph displayed to have different visuals.

Please let me know if this works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests