Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue will trying to use function geocode #193

Open
hbnsarah opened this issue Jun 21, 2023 · 8 comments
Open

Issue will trying to use function geocode #193

hbnsarah opened this issue Jun 21, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@hbnsarah
Copy link

hbnsarah commented Jun 21, 2023

Description

I tried to run my script, using tidygeocoder. It worked perfectly one week ago and now, I get error message:
Error in geocode(., addr, method = "osm", lat = latitude, long = longitude) :
is.character(location) is not TRUE

So I copy pasted also the example you gave on the package description and again, exactly same error message.

What have you tried to resolve the issue? Updating your R packages to their most recent versions can sometimes resolve issues.

Steps to Reproduce

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

library(dplyr, warn.conflicts = FALSE)
library(tidygeocoder)
# create a dataframe with addresses
some_addresses <- tibble::tribble(
 ~name,                  ~addr,
 "White House",          "1600 Pennsylvania Ave NW, Washington, DC",
"Transamerica Pyramid", "600 Montgomery St, San Francisco, CA 94111",     
"Willis Tower",         "233 S Wacker Dr, Chicago, IL 60606"                                  
)
 # geocode the addresses
 lat_longs <- some_addresses %>%
  geocode(addr, method = 'osm', lat = latitude , long = longitude)

#Error in geocode(., addr, method = "osm", lat = latitude, long = longitude) : 
  #is.character(location) is not TRUE
@hbnsarah hbnsarah added the bug Something isn't working label Jun 21, 2023
@jessecambon
Copy link
Owner

Hi @sarahhouben89, I'm not able to reproduce this error. Could you post a reprex and the results of devtools::session_info()?

Here is what I am getting on my system:

library(dplyr, warn.conflicts = FALSE)
library(tidygeocoder)
some_addresses <- tibble::tribble(
  ~name,                  ~addr,
  "White House",          "1600 Pennsylvania Ave NW, Washington, DC",
  "Transamerica Pyramid", "600 Montgomery St, San Francisco, CA 94111",     
  "Willis Tower",         "233 S Wacker Dr, Chicago, IL 60606"                                  
  )
# geocode the addresses
lat_longs <- some_addresses %>%
   geocode(addr, method = 'osm', lat = latitude , long = longitude)
#> Passing 3 addresses to the Nominatim single address geocoder
#> Query completed in: 7.6 seconds

lat_longs
#> # A tibble: 3 × 4
#>   name                 addr                                      latit…¹ longi…²
#>   <chr>                <chr>                                       <dbl>   <dbl>
#> 1 White House          1600 Pennsylvania Ave NW, Washington, DC     38.9   -77.0
#> 2 Transamerica Pyramid 600 Montgomery St, San Francisco, CA 941…    37.8  -122. 
#> 3 Willis Tower         233 S Wacker Dr, Chicago, IL 60606           41.9   -87.6
#> # … with abbreviated variable names ¹​latitude, ²​longitude

Created on 2023-06-21 with reprex v2.0.2

@hbnsarah
Copy link
Author

Hi!
Thx for the quick answer. When I wanted to reproduce it, now, it just worked normally like usual.
Strange thing is that it was not only on my Mac, also on the one of my colleague. exactly same mistake with 3 different scripts which used to work. (and no update in between today)
But well, hopefully it's working again!
Thank you for looking after it!
Have a nice day!

Sarah

@jessecambon
Copy link
Owner

No problem, glad it worked out. Sounds like it could have been a temporary issue with the geocoding service.

@hbnsarah
Copy link
Author

Hello!
This morning, again, same issue for my colleague and I so here is the reprex and the session info also

library(dplyr, warn.conflicts = FALSE)
library(tidygeocoder)
library(leaflet)
library(ggmap)
#> Loading required package: ggplot2
#> ℹ Google's Terms of Service: <https://mapsplatform.google.com>
#> ℹ Please cite ggmap if you use it! Use `citation("ggmap")` for details.
#> 
#> Attaching package: 'ggmap'
#> 
#> 
#> The following object is masked from 'package:tidygeocoder':
#> 
#>     geocode


addresses <- data.frame(capitals = c("Dhaka, Bangladesh",
                                     "Kabul, Afganistan",
                                     "Abu Dhabi, UAE",
                                     "Brussel, Belgium", 
                                     "Brasília, Brazil",
                                     "Washington, D.C., USA",
                                     "Haut-Lomami, Congo",
                                     "Punjab, Pakistan"))


# getting addresses
lat_longs <- addresses %>% geocode(capitals, method = 'osm', lat = latitude , long = longitude)
#> Error in geocode(., capitals, method = "osm", lat = latitude, long = longitude): is.character(location) is not TRUE

Created on 2023-06-22 with reprex v2.0.2

Session info:

─ Session info ────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.2.2 (2022-10-31)
 os       macOS Ventura 13.4
 system   x86_64, darwin17.0
 ui       RStudio
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       Europe/Brussels
 date     2023-06-22
 rstudio  2023.06.0+421 Mountain Hydrangea (desktop)
 pandoc   3.1.1 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/ (via rmarkdown)

─ Packages ────────────────────────────────────────────────────────────────────────────────────────────────────────────
 package      * version date (UTC) lib source
 bitops         1.0-7   2021-04-24 [2] CRAN (R 4.2.0)
 cachem         1.0.8   2023-05-01 [2] CRAN (R 4.2.0)
 callr          3.7.3   2022-11-02 [2] CRAN (R 4.2.0)
 cli            3.6.1   2023-03-23 [1] CRAN (R 4.2.0)
 clipr          0.8.0   2022-02-22 [2] CRAN (R 4.2.0)
 colorspace     2.1-0   2023-01-23 [2] CRAN (R 4.2.0)
 crayon         1.5.2   2022-09-29 [2] CRAN (R 4.2.0)
 crosstalk      1.2.0   2021-11-04 [2] CRAN (R 4.2.0)
 devtools       2.4.5   2022-10-11 [2] CRAN (R 4.2.0)
 digest         0.6.31  2022-12-11 [2] CRAN (R 4.2.0)
 dplyr        * 1.1.2   2023-04-20 [1] CRAN (R 4.2.0)
 ellipsis       0.3.2   2021-04-29 [2] CRAN (R 4.2.0)
 evaluate       0.20    2023-01-17 [2] CRAN (R 4.2.0)
 fansi          1.0.4   2023-01-22 [2] CRAN (R 4.2.0)
 fastmap        1.1.1   2023-02-24 [1] CRAN (R 4.2.0)
 fs             1.6.2   2023-04-25 [1] CRAN (R 4.2.0)
 generics       0.1.3   2022-07-05 [2] CRAN (R 4.2.0)
 ggmap        * 3.0.2   2023-03-14 [2] CRAN (R 4.2.0)
 ggplot2      * 3.4.2   2023-04-03 [2] CRAN (R 4.2.0)
 glue           1.6.2   2022-02-24 [2] CRAN (R 4.2.0)
 gtable         0.3.3   2023-03-21 [2] CRAN (R 4.2.0)
 htmltools      0.5.5   2023-03-23 [2] CRAN (R 4.2.0)
 htmlwidgets    1.6.2   2023-03-17 [1] CRAN (R 4.2.0)
 httpuv         1.6.9   2023-02-14 [2] CRAN (R 4.2.0)
 httr           1.4.6   2023-05-08 [1] CRAN (R 4.2.0)
 jpeg           0.1-10  2022-11-29 [2] CRAN (R 4.2.0)
 knitr          1.42    2023-01-25 [2] CRAN (R 4.2.0)
 later          1.3.0   2021-08-18 [2] CRAN (R 4.2.0)
 lattice        0.21-8  2023-04-05 [2] CRAN (R 4.2.0)
 leaflet      * 2.1.2   2023-03-10 [2] CRAN (R 4.2.0)
 lifecycle      1.0.3   2022-10-07 [2] CRAN (R 4.2.0)
 magrittr       2.0.3   2022-03-30 [2] CRAN (R 4.2.0)
 memoise        2.0.1   2021-11-26 [2] CRAN (R 4.2.0)
 mime           0.12    2021-09-28 [2] CRAN (R 4.2.0)
 miniUI         0.1.1.1 2018-05-18 [2] CRAN (R 4.2.0)
 munsell        0.5.0   2018-06-12 [2] CRAN (R 4.2.0)
 pillar         1.9.0   2023-03-22 [1] CRAN (R 4.2.0)
 pkgbuild       1.4.0   2022-11-27 [2] CRAN (R 4.2.0)
 pkgconfig      2.0.3   2019-09-22 [2] CRAN (R 4.2.0)
 pkgload        1.3.2   2022-11-16 [2] CRAN (R 4.2.0)
 plyr           1.8.8   2022-11-11 [2] CRAN (R 4.2.0)
 png            0.1-8   2022-11-29 [2] CRAN (R 4.2.0)
 prettyunits    1.1.1   2020-01-24 [2] CRAN (R 4.2.0)
 processx       3.8.1   2023-04-18 [2] CRAN (R 4.2.0)
 profvis        0.3.8   2023-05-02 [2] CRAN (R 4.2.0)
 promises       1.2.0.1 2021-02-11 [2] CRAN (R 4.2.0)
 ps             1.7.5   2023-04-18 [2] CRAN (R 4.2.0)
 purrr          1.0.1   2023-01-10 [2] CRAN (R 4.2.0)
 R.cache        0.16.0  2022-07-21 [2] CRAN (R 4.2.0)
 R.methodsS3    1.8.2   2022-06-13 [2] CRAN (R 4.2.0)
 R.oo           1.25.0  2022-06-12 [2] CRAN (R 4.2.0)
 R.utils        2.12.2  2022-11-11 [2] CRAN (R 4.2.0)
 R6             2.5.1   2021-08-19 [2] CRAN (R 4.2.0)
 Rcpp           1.0.10  2023-01-22 [2] CRAN (R 4.2.0)
 remotes        2.4.2   2021-11-30 [2] CRAN (R 4.2.0)
 reprex       * 2.0.2   2022-08-17 [2] CRAN (R 4.2.0)
 RgoogleMaps    1.4.5.3 2020-02-12 [2] CRAN (R 4.2.0)
 rlang          1.1.1   2023-04-28 [1] CRAN (R 4.2.0)
 rmarkdown      2.21    2023-03-26 [2] CRAN (R 4.2.0)
 rstudioapi     0.14    2022-08-22 [2] CRAN (R 4.2.0)
 scales         1.2.1   2022-08-20 [2] CRAN (R 4.2.0)
 sessioninfo    1.2.2   2021-12-06 [2] CRAN (R 4.2.0)
 shiny          1.7.4   2022-12-15 [2] CRAN (R 4.2.0)
 sp             1.6-0   2023-01-19 [2] CRAN (R 4.2.0)
 stringi        1.7.12  2023-01-11 [2] CRAN (R 4.2.0)
 stringr        1.5.0   2022-12-02 [2] CRAN (R 4.2.0)
 styler         1.9.1   2023-03-04 [2] CRAN (R 4.2.0)
 tibble         3.2.1   2023-03-20 [1] CRAN (R 4.2.0)
 tidygeocoder * 1.0.5   2021-11-02 [1] CRAN (R 4.2.0)
 tidyr          1.3.0   2023-01-24 [2] CRAN (R 4.2.0)
 tidyselect     1.2.0   2022-10-10 [2] CRAN (R 4.2.0)
 urlchecker     1.0.1   2021-11-30 [2] CRAN (R 4.2.0)
 usethis        2.1.6   2022-05-25 [2] CRAN (R 4.2.0)
 utf8           1.2.3   2023-01-31 [2] CRAN (R 4.2.0)
 vctrs          0.6.2   2023-04-19 [1] CRAN (R 4.2.0)
 withr          2.5.0   2022-03-03 [2] CRAN (R 4.2.0)
 xfun           0.39    2023-04-20 [1] CRAN (R 4.2.0)
 xtable         1.8-4   2019-04-21 [2] CRAN (R 4.2.0)
 yaml           2.3.7   2023-01-23 [2] CRAN (R 4.2.0)

 [1] /Users/shouben/Library/R/x86_64/4.2/library
 [2] /Library/Frameworks/R.framework/Versions/4.2/Resources/library

@jessecambon
Copy link
Owner

Hi @sarahhouben89, that is an odd error. I haven't been able to reproduce it on my end, but next time it happens can you run traceback() and post the results? That way we can see more detail on that error.

https://adv-r.hadley.nz/debugging.html#debugging

@hbnsarah
Copy link
Author

Hello!
Sure!
Like that?

traceback()
4: stop(simpleError(msg, call = if (p <- sys.parent(1L)) sys.call(p)))
3: stopifnot(is.character(location))
2: geocode(., capitals, method = "osm", lat = latitude, long = longitude)
1: addresses %>% geocode(capitals, method = "osm", lat = latitude,
long = longitude)

@jessecambon
Copy link
Owner

Sorry, I forgot that won't show the files/packages involved. Can you try this command instead?

rlang::last_trace()

@hbnsarah
Copy link
Author

rlang::last_trace()
Error: Can't show last error because no error was recorded yet

Mmmm this time, not conclusive but still same issue and same script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants