I have just installed OpenStreetMap package. I tried to run this:
openmap(c(-8.17201, 113.65975), c(-8.1907, 113.6958))
and I got this error message:
Error in if (substring(type, 1L, 4L) == "http") type else match.arg(type) : the condition has length > 1
I then tried to run the code in the Example
#plot Korea with ggplot2.
library(ggplot2)
map <- openmap(c(43.46886761482925,119.94873046875),
c(33.22949814144951,133.9892578125),
minNumTiles=4)
autoplot(map)
Surprisingly, I got the same error message.
I found a solution, which is to specify type = "osm", from here: https://stackoverflow.com/questions/76489384/error-when-using-openmap-function-openstreetmap-package-in-r
So I run:
#plot Korea with ggplot2.
library(ggplot2)
map <- openmap(c(43.46886761482925,119.94873046875),
c(33.22949814144951,133.9892578125),
minNumTiles=4, type = "osm")
autoplot(map)
The error message above disappeared, but I got another error message:
Error in `autoplot()`:
! Objects of class <OpenStreetMap> are not supported by autoplot.
ℹ have you loaded the required package?
Run `rlang::last_trace()` to see where the error occurred.
There is no error when I run plot(map). The error occurred only in running autoplot(map).
Here is my session info:
R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22621)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8
time zone: Asia/Bangkok
tzcode source: internal
attached base packages:
[1] stats graphics grDevices datasets utils methods base
other attached packages:
[1] ggplot2_3.4.3 OpenStreetMap_0.3.4
loaded via a namespace (and not attached):
[1] gtable_0.3.4 dplyr_1.1.3 compiler_4.3.1 renv_1.0.2
[5] tidyselect_1.2.0 Rcpp_1.0.11 scales_1.2.1 yaml_2.3.7
[9] lattice_0.21-8 R6_2.5.1 generics_0.1.3 classInt_0.4-10
[13] sf_1.0-14 tibble_3.2.1 units_0.8-3 munsell_0.5.0
[17] DBI_1.1.3 pillar_1.9.0 rlang_1.1.1 rgdal_1.6-7
[21] utf8_1.2.3 sp_2.0-0 terra_1.7-46 cli_3.6.1
[25] withr_2.5.0 magrittr_2.0.3 class_7.3-22 grid_4.3.1
[29] rstudioapi_0.14 rJava_1.0-6 lifecycle_1.0.3 vctrs_0.6.3
[33] KernSmooth_2.23-21 proxy_0.4-27 glue_1.6.2 raster_3.6-23
[37] codetools_0.2-19 fansi_1.0.4 e1071_1.7-13 colorspace_2.1-0
[41] tools_4.3.1 pkgconfig_2.0.3
I have just installed OpenStreetMap package. I tried to run this:
openmap(c(-8.17201, 113.65975), c(-8.1907, 113.6958))and I got this error message:
Error in if (substring(type, 1L, 4L) == "http") type else match.arg(type) : the condition has length > 1I then tried to run the code in the Example
Surprisingly, I got the same error message.
I found a solution, which is to specify
type = "osm", from here: https://stackoverflow.com/questions/76489384/error-when-using-openmap-function-openstreetmap-package-in-rSo I run:
The error message above disappeared, but I got another error message:
There is no error when I run
plot(map). The error occurred only in runningautoplot(map).Here is my session info: