I am using ggmap package in R software in order to geocode a list of addresses. The counting is over 2500 - Googles diary quota for free users.
I have been searched about it and I found out that it is possible to geocode 100 thousand addresses per day if you have an account. I decided to open an account and I received a message that I have 60 trial days and they gave a 300 dollars credit. Despite this, I didnt discover where I can find the "client" and "signature" options that ggmap requires.
If someone can tell me where I can find it, please let me know!
My aim is to make Google searches by the address. If address is not recognized, then I make it searches for the local using the zip code. Here is what I am doing:
library(RJSONIO)
library(RCurl)
getGeoData <- function(location, api_key){
location <- gsub(' ','+',location)
geo_data <- getURL(paste("https://maps.googleapis.com/maps/api/geocode/json?address=",location,sprintf("&key=%s",api_key), sep=""))
geo_data <- fromJSON(geo_data)
if(geo_data$status=="ZERO_RESULTS"){
return(NA)
} else return(geo_data$results[[1]]$geometry$location)
}
New error:
getGeoData(basefinal$cep[6793], "MY KEY")[[2]]
Error in getGeoData(basefinal$cep[6793], "MY KEY")[[2]] :
subscript out of bounds
Related
I am trying to get lat long for Indian cities through ggmap package. Below is the code I have tried but it results in an error.
I created a vector with sample cities
library(ggmap)
mycities1<- c("Hyderabad","Chennai","Bangalore","Cochin","ARNHEM","London")
str(mycities1)
geocode(mycities1[1])
This is throwing out NA values though my city names are class of character.
Warning message: geocode failed with status OVER_QUERY_LIMIT, location
= "Hyderabad
Please change the source argument to dsk.
geocode(as.character(mycities1[1]), source = "dsk")
This is due to recent google-API changes.
There is also a current github-issue (or several actually) which adresses that problem.
geocode failed with status OVER_QUERY_LIMIT, location = "XXX" --> you
have not registered a correct and billing-enabled Google Maps API key
using register_google() (ggmap v2.7,903). Enabling billing is a
specific step after (!) adding your credit card information.
I want to create a data frame in R with name of districts and their long and lat. For this purpose, I gave the command:
>locations_df <- mutate_geocode(cities_df, district)
This commands used the maps.googleapis.com for the purpose of geocoding, but for my 13 districts I am getting NA error. One of the error is pasted below:
geocode failed with status OVER_QUERY_LIMIT, location = "Sukkur"
How can I provide the geocode for missing values? I checked the name of missed cities on google map for spelling error but no such error was seen.
Thank you for the help.
Honestly your best bet may be to try running the query again. The results seem pretty idiosyncratic as far as I can tell (possibly related to dynamic IPs over WiFi?). These are my results from just now.
df %>% mutate_geocode(address)
Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Sukkur&sensor=false
address lon lat
1 Sukkur NA NA
Warning message:
geocode failed with status OVER_QUERY_LIMIT, location = "Sukkur"
So it failed for me too. I checked the queries I had left, then added "Paris" to check its results.
geocodeQueryCheck()
2499 geocoding queries remaining.
df
address
1 Sukkur
df[2,1]<-"Paris"
df %>% mutate_geocode(address)
Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Sukkur&sensor=false
Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Paris&sensor=false
address lon lat
1 Sukkur 68.822808 27.72436
2 Paris 2.352222 48.85661
And now it works!
The issue may be helped by obtaining a Google Maps API key as this question suggests, which you can use if you install the GitHub version of ggmap.
The other option is to iterate through requests as an answer here suggests.
I have seen a few posts about this, but I have not been able to use any of the suggested code for the way I have my program set up. I am not very good at R but I need this information for a Political Science class. Could someone please help me figure out a way to avoid receiving the error message "Warning message: In twInterfaceObj$doAPICall(cmd, params, method, ...) : Rate limit encountered & retry limit reached - returning partial results." Thank you in advance! The code I am running is below:
# install and load packages
install.packages("twitteR")
install.packages("ROAuth")
install.packages("base64enc")
install.packages("plyr")
library("twitteR")
library("ROAuth")
library("base64enc")
library("plyr")
# Establish the connection (do this once)
cred$handshake(cainfo="cacert.pem")
#setup Twitter
setup_twitter_oauth('Consumer Key - XXXXXXXXXX', Consumer Secret -
'XXXXXXXXXX', API Key - 'XXXXXXXXXX', API Secret - 'XXXXXXX')
#store the user
user <- getUser('JackPosobiec')
#return a list of followers
Posobiecfollowers <- user$getFollowers(n=NULL)
Posobiecfollowers
#save followers in a data set
followers.df = ldply(followers, function(t) t$toDataFrame())
write.csv(followers.df, file = "JackPosobiecfollowersfile.csv")
I have problems with R package getReturns. I have encountered this error since 17th May:
Warning in file(file, "rt") :
cannot open URL 'http://ichart.finance.yahoo.com/table.csv?s=AAPL&a=4&b=28&c=2014&d=4&e=27&f=2017&g=w&ignore=.csv': HTTP status was '404 Not Found'
It looks like that ichart API did not run anymore. Can anyone help me with this issue? Does someone know how to fix it? I have encountered the same issue with the quantmod R package.
I have encountered this problem as well. Yahoo! has taken down ichart and the open-source libraries that rely on it are now broken. Yahoo! also has no plans to introduce a replacement. For more information, see this post on Yahoo!'s Forums.
I switched to eodhistoricaldata.com after Yahoo failed, several weeks ago I found good alternative with an API very similar to Yahoo Finance.
Basically, for almost all R scripts I use I just changed this:
URL <- paste0("ichart.finance.yahoo.com/table.csv?s=", symbols[i])
to:
URL <- paste0("eodhistoricaldata.com/api/table.csv?s=", symbols[i])
Then add an API key and it will work in the same way as before. I saved a lot of time for my R scripts on it.
You can follow my an earlier post, which might help you.
I tried :
library(quantmod)
# Create an object containing the Pfizer ticker symbol
symbol <- "PFE"
# Use getSymbols to import the data
getSymbols(symbol, src="yahoo", auto.assign=T)
# because src='google' throws error, yahoo was used, and even that is down
When I tried other source, it worked:
# "quantmod::oanda.currencies" contains a list of currencies provided by Oanda.com
currency_pair <- "GBP/CAD"
# Load British Pound to Canadian Dollar exchange rate data
getSymbols(currency_pair, src="oanda")
str(GBPCAD)
It seems there are issues with google and yahoo while we use quantmod pkg.
I will suggest you to use 'Quandl' instead. Plz goto Quandl website, register for free and create API key, and then copy it in below:
# Install Quandl
install.packages("Quandl")
# or from github
install.packages("devtools")
library(devtools)
install_github("quandl/quandl-r")
# Load the Quandl package
library(Quandl)
# use API for full access
Quandl.api_key("xxxxxx")
# Download APPLE stock data
mydata = Quandl::Quandl.datatable("ZACKS/FC", ticker="AAPL")
For HDFC at BSE, you can use:
hdfc = Quandl("BSE/BOM500180")
for more details:
https://www.quandl.com/data/BSE-Bombay-Stock-Exchange?keyword=HDFC
I'm attempting to find the coordinates for several cities in Ghana. I've used the geocode function in taRifx.geo with the "google" option and had success, but Google doesn't know where all my cities are.
I'd like to use the Bing service to fill in the coordinates that were missing from my Google list and I'm starting with just one city ("Awutu Breku") to make sure the code works. I run this code, though, and get an error:
> Bkey <- "______________(my key would be here)____"
> Loc5 <- geocode("Awutu Breku", service="bing", BingMapsKey = Bkey,
+ returntype="coordinates")
Error in geocode.default("Awutu Breku", service = "bing", BingMapsKey = Bkey, :
To use Bing, you must save your Bing Maps API key (obtain at http://msdn.microsoft.com/en-us/library/ff428642.aspx) using options(BingMapsKey='mykey').
This error is very confusing since I do include the BingMapsKey argument but the function doesn't seem to be recognizing it.
I've searched quite a bit for an answer to this one and haven't come across anything. I even looked on the github page but couldn't figure out what might be wrong with my code. I feel like I'm missing something simple. Any help would be appreciated!
I needed to do a devtools::install_github("gsk3/taRifx.geo") to be able to use the geocode function and the instructions clearly state that you need to do a:
options(BingMapsKey='ridiculously_long_string')
before calling using the bing option:
geocode("1600 Pennsylvania Ave NW, Washington, DC 20500", service="bing")
## [1] 38.89719 -77.03655