jessecambon / tidygeocoder

Geocoding Made Easy

Home Page:https://jessecambon.github.io/tidygeocoder

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

batch geocoding using here api

ashishchalise5 opened this issue · comments

Description

I am using the same dataset for both single geocoding and batch geocoding however the single geocoding works fine batch encoding doesnot give any lat long values

Steps to Reproduce

Include a small code example that someone else can run to reproduce the bug:

vendors<- read_csv("https://drive.google.com/uc?export=download&id=13oEQvP2sYwjNTKBVLat8mbp881mvpNkr")
location2<- tidygeocoder::geo(vendors$`Full Address`,method="here",mode="batch")
View(location2)

Result:
Passing 289 addresses to the HERE batch geocoder
Error:
Query completed in: 1.8 seconds

This appears to be a problem caused by the "#" character in the third address:

> vendors$`Full Address`[3]
[1] "Unit#6 - 421 Sandwich Street South Amherstburg, Ontario N9V 3K8"

Here's the error I get:

> vendors$`Full Address`[1:3] |> tidygeocoder::geo(method="here",mode="batch")
Passing 3 addresses to the HERE batch geocoder
Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec,  : 
  line 3 did not have 6 elements

When I remove the # character it works:

> vendors$`Full Address`[1:3] |> stringr::str_replace_all("#", " ") |> tidygeocoder::geo(method="here",mode="batch")
Passing 3 addresses to the HERE batch geocoder
Query completed in: 28.8 seconds
# A tibble: 3 × 3
  address                                                           lat  long
  <chr>                                                           <dbl> <dbl>
1 15 Westney Rd N Ajax, Ontario L1T 1P5                            43.9 -79.0
2 50 King St S Alliston, Ontario L9R 1H6                           44.1 -79.9
3 Unit 6 - 421 Sandwich Street South Amherstburg, Ontario N9V 3K8  42.1 -83.1

For the next release we can look at trying to escape these characters within tidygeocoder, but for now you can remove the character manually like I did above. Issue #190 is also related to escaping characters.

@dieghernan

Hey, I am having a similar issue; however, I already tidied my address to remove any special characters. Here's a reprex —also, I included a tilde, however it makes no difference if I remove it:

library(dplyr)

library(sf)
library(tidygeocoder)

df <- tibble::tibble(
  street_name = c("rua são paulo", "av prof alfredo balena", "av getulio vargas"),
  street_number = c(656, 400, 1300),
  postcode = c(30170130, 30130100, 30112021)
)

# this works
df <- df %>% 
  mutate(query = paste0(street_name, ", ", street_number, " - ", postcode)) %>% 
  geocode(address = query, method = "here")

# this doesn't 
df <- df %>% 
  mutate(query = paste0(street_name, ", ", street_number, " - ", postcode)) %>% 
  geocode(address = query, method = "here", mode = "batch")

As happened to @ashishchalise5, it's just an empty error message, so I have no clue about what's happening.

Btw, i found that method = "here" is very smooth compared to others. I was using arcgis, and now I'm using here to geocode the addresses arcgis couldn't find, and there's a high rate of success; however, it would be better if I could batch them!