sandbox/reverse_queries/iq_reverse.R

url_base  <- tidygeocoder:::get_iq_url(region = 'us', reverse = TRUE)


soup <- httr::GET(url = url_base, 
                  query = list(lat = 6.455027, 
                         #      lon = 3.384082,
                               lon = NA,
                               limit = 1,
                               format = 'json'
                                 ))

response <- jsonlite::fromJSON(httr::content(soup, as = 'text', encoding = "UTF-8"))


# results_full <- cbind(response[!(names(response) %in% c('display_name', 'boundingbox', 'address'))], 
#       tibble::as_tibble(response[['address']]), tibble::tibble(boundingbox = list(response$boundingbox))) 


results_full <- tidygeocoder:::extract_reverse_results('iq', response)


#f_address <- raw_results$display_name
#df_not_address <- raw_results[!(names(raw_results) %in% c('display_name', 'boundingbox'))]

#lapply(full_list, function(x) do.call(rbind, x))

#full_results <- dplyr::bind_cols(df_address, df_not_address)


#results <- tidygeocoder::extract_results(selected_method, raw_results)
jessecambon/tidygeocoder documentation built on Jan. 26, 2023, 4:03 p.m.