Search code examples
rgoogle-mapsgeocode

Geocode Error Zero Result in R


I'm currently using the google maps in R (I suppose it would be correct if I said I'm calling the google map API in R, is that right?).

Some of my address entries are not complete so the API returns an error. This is annoying because any valid addresses are not decoded after the error. Is there a way to skip the invalid addresses? Something like this:

Error in if (gc$status != "OK") { : argument is of length zero

In addition, it would be nice to have a message about the failing addresses. Something like:

Warning message: geocode failed with status ZERO_RESULTS, location = "XXX ST , SAN FRANCISC" 

I'm using: loc1 <- geocode(as.character(TestAddress2$Address))


Solution

  • I discovered that the geocode call only returns warning for addresses it can't find. Thus the real problem was the fact that when there was no value for address it gave an error.

    Thus I filtered out observations that did not have a value:

    TestAddress2<- TestAddress2[!(TestAddress2$Address== " "),]