ropensci / osmextract

Download and import OpenStreetMap data from Geofabrik and other providers
https://docs.ropensci.org/osmextract
GNU General Public License v3.0
170 stars 12 forks source link

oe_get - Error in ...names() : could not find function "...names" #241

Closed adithirgis closed 2 years ago

adithirgis commented 2 years ago

Hi! I want to use OSM data using R and I found this wonderful package osmextract. But when I run a simple command to download all polylines available in OSM for India, I get this error shown below. Any help is appreciated, thanks! (This error comes up even when I try to use the examples shown in the README of osmextract). I saw this, but sorry could not understand much.

library(sf)
library(osmextract)
oe_get(place = "India", layer = "lines", provider = "geofabrik", match_by = "name") 
# The input place was matched with: India
# Error in ...names() : could not find function "...names"
agila5 commented 2 years ago

Hi @adithirgis and thanks for your message. Can you share the output of the following code?

library(sf)
library(osmextract)
sessionInfo()

Thanks.

adithirgis commented 2 years ago

Thanks for the response, here -

> library(sf)
Linking to GEOS 3.9.1, GDAL 3.2.1, PROJ 7.2.1; sf_use_s2() is TRUE
> library(osmextract)
Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright.
Check the package website, https://docs.ropensci.org/osmextract/, for more details.
> sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=English_India.1252  LC_CTYPE=English_India.1252   
[3] LC_MONETARY=English_India.1252 LC_NUMERIC=C                  
[5] LC_TIME=English_India.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] osmextract_0.4.0.9000 sf_1.0-5             

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.7         spdep_1.2-2        pillar_1.6.4      
 [4] compiler_4.0.5     cellranger_1.1.0   class_7.3-18      
 [7] tools_4.0.5        boot_1.3-27        corrplot_0.84     
[10] rgee_1.1.0         jsonlite_1.7.2     lifecycle_1.0.1   
[13] tibble_3.1.4       lattice_0.20-41    png_0.1-7         
[16] pkgconfig_2.0.3    rlang_0.4.11       Matrix_1.3-2      
[19] cli_3.0.1          DBI_1.1.1          spData_0.3.10     
[22] terra_1.4-11       e1071_1.7-7        s2_1.0.7          
[25] dplyr_1.0.7        raster_3.5-11      generics_0.1.0    
[28] vctrs_0.3.8        classInt_0.4-3     rprojroot_2.0.2   
[31] grid_4.0.5         tidyselect_1.1.0   reticulate_1.20   
[34] glue_1.6.0         here_1.0.1         R6_2.5.1          
[37] processx_3.5.0     fansi_0.4.2        readxl_1.3.1      
[40] sp_1.4-5           deldir_0.2-10      purrr_0.3.4       
[43] magrittr_2.0.1     ps_1.6.0           codetools_0.2-18  
[46] ellipsis_0.3.2     units_0.7-1        assertthat_0.2.1  
[49] utf8_1.2.1         KernSmooth_2.23-18 proxy_0.4-25      
[52] wk_0.6.0           crayon_1.4.2    
agila5 commented 2 years ago

Dear @adithirgis, I'm sorry but I can't reproduce your problem so I'm not sure how to help you. Did you load any other package before running oe_get? Did you modify any global options? Could you create a reprex (preferably with the smaller OSM extract that creates the problem)?

I also don't get any error with R v4.1.2 or v4.0.5.

adithirgis commented 2 years ago

Hi!

Thanks for looking into this, I also could not find out the problem, as when I use RStudio Cloud, it all works perfectly well. I am not able to use this on my Windows system. Let me know if I am missing anything, I also did try osmextract::oe_get. Once again thank you for the package. No, I did not touch any global options, and yes, I think I load sf before osmextract.

Here is what I get using reprex -

library(osmextract)
#> Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright.
#> Check the package website, https://docs.ropensci.org/osmextract/, for more details.
#> Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright.
#> Check the package website, https://docs.ropensci.org/osmextract/, for more details.
library(sf)
#> Linking to GEOS 3.9.1, GDAL 3.2.1, PROJ 7.2.1; sf_use_s2() is TRUE
#> Linking to GEOS 3.9.1, GDAL 3.2.1, PROJ 7.2.1; sf_use_s2() is TRUE
cycleways_england = oe_get(
  "England",
  quiet = FALSE,
  query = "SELECT * FROM 'lines' WHERE highway = 'cycleway'"
)
#> The input place was matched with: England
#> Error in ...names(): could not find function "...names"
#> The input place was matched with: England
#> Error in ...names(): could not find function "...names"

reprex::reprex(session_info = TRUE)
#> i Non-interactive session, setting `html_preview = FALSE`.
#> CLIPR_ALLOW has not been set, so clipr will not run interactively
#> Error in switch(where, expr = stringify_expression(x_expr), clipboard = ingest_clipboard(), : EXPR must be a length 1 vector
#> i Non-interactive session, setting `html_preview = FALSE`.
#> CLIPR_ALLOW has not been set, so clipr will not run interactively
#> Error in switch(where, expr = stringify_expression(x_expr), clipboard = ingest_clipboard(), : EXPR must be a length 1 vector

Created on 2022-02-05 by the reprex package (v2.0.1)

Session info ``` r sessioninfo::session_info() #> - Session info --------------------------------------------------------------- #> setting value #> version R version 4.0.5 (2021-03-31) #> os Windows 10 x64 #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate English_India.1252 #> ctype English_India.1252 #> tz Asia/Calcutta #> date 2022-02-05 #> #> - Packages ------------------------------------------------------------------- #> package * version date lib source #> assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.4) #> backports 1.2.1 2020-12-09 [1] CRAN (R 4.0.3) #> class 7.3-18 2021-01-24 [1] CRAN (R 4.0.5) #> classInt 0.4-3 2020-04-07 [1] CRAN (R 4.0.5) #> cli 3.0.1 2021-07-17 [1] CRAN (R 4.0.5) #> clipr 0.7.1 2020-10-08 [1] CRAN (R 4.0.4) #> crayon 1.4.2 2021-10-29 [1] CRAN (R 4.0.5) #> DBI 1.1.1 2021-01-15 [1] CRAN (R 4.0.4) #> digest 0.6.29 2021-12-01 [1] CRAN (R 4.0.5) #> dplyr 1.0.7 2021-06-18 [1] CRAN (R 4.0.5) #> e1071 1.7-7 2021-05-23 [1] CRAN (R 4.0.5) #> ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.0.5) #> evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.4) #> fansi 0.4.2 2021-01-15 [1] CRAN (R 4.0.4) #> fs 1.5.0 2020-07-31 [1] CRAN (R 4.0.4) #> generics 0.1.0 2020-10-31 [1] CRAN (R 4.0.4) #> glue 1.6.0 2021-12-17 [1] CRAN (R 4.0.5) #> highr 0.9 2021-04-16 [1] CRAN (R 4.0.5) #> htmltools 0.5.1.1 2021-01-22 [1] CRAN (R 4.0.4) #> KernSmooth 2.23-18 2020-10-29 [1] CRAN (R 4.0.5) #> knitr 1.37 2021-12-16 [1] CRAN (R 4.0.5) #> lifecycle 1.0.1 2021-09-24 [1] CRAN (R 4.0.5) #> magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.0.4) #> osmextract * 0.4.0.9000 2021-12-07 [1] Github (ropensci/osmextract@7b29afc) #> pillar 1.6.4 2021-10-18 [1] CRAN (R 4.0.5) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.4) #> proxy 0.4-25 2021-03-05 [1] CRAN (R 4.0.5) #> purrr 0.3.4 2020-04-17 [1] CRAN (R 4.0.4) #> R6 2.5.1 2021-08-19 [1] CRAN (R 4.0.5) #> Rcpp 1.0.7 2021-07-07 [1] CRAN (R 4.0.5) #> reprex 2.0.1 2021-08-05 [1] CRAN (R 4.0.5) #> rlang 0.4.11 2021-04-30 [1] CRAN (R 4.0.5) #> rmarkdown 2.11 2021-09-14 [1] CRAN (R 4.0.5) #> rstudioapi 0.13 2020-11-12 [1] CRAN (R 4.0.4) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.5) #> sf * 1.0-5 2021-12-17 [1] CRAN (R 4.0.5) #> stringi 1.7.6 2021-11-29 [1] CRAN (R 4.0.5) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.0.4) #> styler 1.4.1 2021-03-30 [1] CRAN (R 4.0.5) #> tibble 3.1.4 2021-08-25 [1] CRAN (R 4.0.5) #> tidyselect 1.1.0 2020-05-11 [1] CRAN (R 4.0.4) #> units 0.7-1 2021-03-16 [1] CRAN (R 4.0.5) #> utf8 1.2.1 2021-03-12 [1] CRAN (R 4.0.4) #> vctrs 0.3.8 2021-04-29 [1] CRAN (R 4.0.5) #> withr 2.4.3 2021-11-30 [1] CRAN (R 4.0.5) #> xfun 0.29 2021-12-14 [1] CRAN (R 4.0.5) #> yaml 2.2.1 2020-02-01 [1] CRAN (R 4.0.4) #> #> [1] D:/R/library ```

And in the console I get

> library(osmextract)
Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright.
Check the package website, https://docs.ropensci.org/osmextract/, for more details.
> library(sf)
Linking to GEOS 3.9.1, GDAL 3.2.1, PROJ 7.2.1; sf_use_s2() is TRUE
> cycleways_england = oe_get(
+   "England",
+   quiet = FALSE,
+   query = "SELECT * FROM 'lines' WHERE highway = 'cycleway'"
+ )
The input place was matched with: England
Error in ...names() : could not find function "...names"

Thanks Adithi

agila5 commented 2 years ago

I just noticed that ...names() function was introduced in R 4.1. I will fix that immediately. Thanks for your report.

agila5 commented 2 years ago

Dear @adithirgis, I finally figured out the problem but, unfortunately, none of the tested solutions works for R < 4.1 (see tests in #243). I really don't want to add a strong dependency forcing R >= 4.1 but, for the moment, my only suggestion is to run the code on Rstudio Cloud (or any other approach that runs R >= 4.1). Sorry.

adithirgis commented 2 years ago

Hello @agila5,

Thank you so much for trying, I will update R sometime or use RStudio Cloud of the version mentioned. Thanks again! Please feel free to close the issue. Thank you!

agila5 commented 2 years ago

Hi @adithirgis. I think I fixed the problem that you mentioned with the last commit. If you are still getting any errors/problems, please let me know.

Thanks again for raising this issue.

adithirgis commented 2 years ago

Hello,

Thank you! Should I reinstall the package again?

agila5 commented 2 years ago

Yes, with the following command: remotes::install_github("ropensci/osmextract")