Skip to content

help_ReverseGeocoding

4 messages · shreya ghosh, MacQueen, Don, Bob Rudis

#
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.
#
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
#
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:
#
Thank you for your suggestion. Is there any open source api that won't
rate-limit it?
On Tue, Jul 28, 2015 at 9:38 PM, boB Rudis <bob at rudis.net> wrote: