Hi, I'm trying to do reversegeocoding on a large dataset. I'm using "RJSONIO" library and using Google map API to get the location of the given lat-lon in the dataset. After 100 or 150 successful displaying location information it is showing Warning message - "In readLines(con) : cannot open: HTTP status was '0 (null)'" and Error : "Error in fromJSON(paste(readLines(con), collapse = "")) : error in evaluating the argument 'content' in selecting a method for function 'fromJSON': Error in readLines(con) : cannot open the connection" Please help me to solve the issue. location function is as follows : location<-function(latlng){ latlngStr <- gsub(' ','%20', paste(latlng, collapse=",")) library("RJSONIO") #Load Library #Open Connection connectStr <- paste(' http://maps.google.com/maps/api/geocode/json?sensor=false&latlng=',latlngStr, sep="") con <- url(connectStr) data.json <- fromJSON(paste(readLines(con), collapse="")) close(con) data.json <- unlist(data.json) if(data.json["status"]=="OK") address <- data.json["results.formatted_address"] print (address) } I'm using R version 3.2.1 and Ubuntu 14.10 OS. Thank you. -- Shreya Ghosh *9007448845* -- The mind is not a vessel to be filled, but a fire to be kindled [[alternative HTML version deleted]]
My first guess, after a quick glance, is that Google only lets you do a limited number of lookups within some period of time. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 7/27/15, 10:14 PM, "R-help on behalf of shreya ghosh" <r-help-bounces at r-project.org on behalf of shreya.cst at gmail.com> wrote:>Hi, >I'm trying to do reversegeocoding on a large dataset. I'm using "RJSONIO" >library and using Google map API to get the location of the given lat-lon >in the dataset. After 100 or 150 successful displaying location >information >it is showing > Warning message - "In readLines(con) : cannot open: HTTP status was '0 >(null)'" >and Error : "Error in fromJSON(paste(readLines(con), collapse = "")) : > error in evaluating the argument 'content' in selecting a method for >function 'fromJSON': Error in readLines(con) : cannot open the connection" > >Please help me to solve the issue. > >location function is as follows : > >location<-function(latlng){ > latlngStr <- gsub(' ','%20', paste(latlng, collapse=",")) > library("RJSONIO") #Load Library > #Open Connection > connectStr <- paste(' >http://maps.google.com/maps/api/geocode/json?sensor=false&latlng=',latlngS >tr, >sep="") > con <- url(connectStr) > data.json <- fromJSON(paste(readLines(con), collapse="")) > close(con) > > data.json <- unlist(data.json) > if(data.json["status"]=="OK") > address <- data.json["results.formatted_address"] > print (address) >} > >I'm using R version 3.2.1 and Ubuntu 14.10 OS. > >Thank you. > > > >-- > >Shreya Ghosh > >*9007448845* > >-- The mind is not a vessel to be filled, but a fire to be kindled > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code.
You should use ggmap::revgeocode (it calls google's api) and google will rate-limit you. There are also packages to use HERE maps geo/revgeo lookups http://blog.corynissen.com/2014/10/making-r-package-to-use-here-geocode-api.html and the geocode package has GNfindNearestAddress, so tons of options to choose from. On Tue, Jul 28, 2015 at 11:30 AM, MacQueen, Don <macqueen1 at llnl.gov> wrote:> My first guess, after a quick glance, is that Google only lets you do a > limited number of lookups within some period of time. > > -Don > > -- > Don MacQueen > > Lawrence Livermore National Laboratory > 7000 East Ave., L-627 > Livermore, CA 94550 > 925-423-1062 > > > > > > On 7/27/15, 10:14 PM, "R-help on behalf of shreya ghosh" > <r-help-bounces at r-project.org on behalf of shreya.cst at gmail.com> wrote: > >>Hi, >>I'm trying to do reversegeocoding on a large dataset. I'm using "RJSONIO" >>library and using Google map API to get the location of the given lat-lon >>in the dataset. After 100 or 150 successful displaying location >>information >>it is showing >> Warning message - "In readLines(con) : cannot open: HTTP status was '0 >>(null)'" >>and Error : "Error in fromJSON(paste(readLines(con), collapse = "")) : >> error in evaluating the argument 'content' in selecting a method for >>function 'fromJSON': Error in readLines(con) : cannot open the connection" >> >>Please help me to solve the issue. >> >>location function is as follows : >> >>location<-function(latlng){ >> latlngStr <- gsub(' ','%20', paste(latlng, collapse=",")) >> library("RJSONIO") #Load Library >> #Open Connection >> connectStr <- paste(' >>http://maps.google.com/maps/api/geocode/json?sensor=false&latlng=',latlngS >>tr, >>sep="") >> con <- url(connectStr) >> data.json <- fromJSON(paste(readLines(con), collapse="")) >> close(con) >> >> data.json <- unlist(data.json) >> if(data.json["status"]=="OK") >> address <- data.json["results.formatted_address"] >> print (address) >>} >> >>I'm using R version 3.2.1 and Ubuntu 14.10 OS. >> >>Thank you. >> >> >> >>-- >> >>Shreya Ghosh >> >>*9007448845* >> >>-- The mind is not a vessel to be filled, but a fire to be kindled >> >> [[alternative HTML version deleted]] >> >>______________________________________________ >>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >>https://stat.ethz.ch/mailman/listinfo/r-help >>PLEASE do read the posting guide >>http://www.R-project.org/posting-guide.html >>and provide commented, minimal, self-contained, reproducible code. > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.