0

I have a data.frame (df) with addresses. I want to geocode them. My code:

for(i in 1:nrow(df))
{
  # Print("Working...")
  result <- geocode(df$address[i], output = "latlona", source = "google")
  df$lon[i] <- as.numeric(result[1])
  df$lat[i] <- as.numeric(result[2])
}

The output and error is the following:

 Error in chartr(" ", "+", location) : 
  invalid input 'Joaquín Requena esquina Charrúa 1111' in 'utf8towcs'
In addition: Warning messages:
1: geocode failed with status ZERO_RESULTS, location = "a pasos de OSE 0000" 
2: geocode failed with status ZERO_RESULTS, location = "Luis Galvani 1111" 

Any help?

Thank you!

Pablo P.
  • 13
  • 8
  • 3
    It's telling you the geocode failed, so your `result` object doesn't have a 3rd column. Which means `result[3]` won't work (and therefore gives you the error you're seeing). – SymbolixAU Aug 24 '18 at 04:31
  • [this might be a related issue](https://stackoverflow.com/a/51714277/5977215) – SymbolixAU Aug 25 '18 at 21:20

0 Answers0