0
votes

While I was trying the code below, I get the following error message.

my.Map <- get_map(location ="Singapore",source = "osm",zoom = 10)
 ggmap(my.Map)

Error message:

Error in zero_range(from) : x must be length 1 or 2

I have tried the same with multiple examples and reloading the package, I am unable to figure out how to solve this as it involves just querying google maps and plotting them.

Below is my sessionInfo

R version 3.3.0 (2016-05-03) Platform: x86_64-apple-darwin13.4.0 (64-bit) Running under: OS X 10.11.5 (El Capitan)

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages: [1] ggmap_2.6.1        ggplot2_2.1.0.9001

loaded via a namespace (and not attached):  [1] Rcpp_0.12.7       plyr_1.8.4        tools_3.3.0       digest_0.6.10      [5] evaluate_0.9      tibble_1.2        gtable_0.2.0      lattice_0.20-34  [9] png_0.1-7         shiny_0.14        rstudioapi_0.6    mapproj_1.2-4     [13] yaml_2.1.13       proto_0.3-10      stringr_1.1.0     knitr_1.14        [17] RgoogleMaps_1.4.1 maps_3.1.1  grid_3.3.0        R6_2.1.3          [21] jpeg_0.1-8        rmarkdown_1.1     bookdown_0.1      sp_1.2-3          [25] reshape2_1.4.1    magrittr_1.5      scales_0.4.0.9003 htmltools_0.3.5  [29] assertthat_0.1    mime_0.5          xtable_1.8-2      colorspace_1.2-6  [33] geosphere_1.5-5   httpuv_1.3.3      labeling_0.3      stringi_1.1.1     [37] miniUI_0.1.1      lazyeval_0.2.0    munsell_0.4.3     rjson_0.2.15

Description of my.Map

str(my.Map)
chr [1:607, 1:607] "#F2EFE9" "#F2EFE9" "#F2EFE9" "#F2EFE9" "#F2EFE9" ...
- attr(*, "class")= chr [1:2] "ggmap" "raster"
- attr(*, "bb")='data.frame':   1 obs. of  4 variables:
..$ ll.lat: num 0.912
..$ ll.lon: num 103      ..$ ur.lat: num 1.79
..$ ur.lon: num 104
- attr(*, "source")= chr "osm"
- attr(*, "maptype")= chr "openstreetmap"
- attr(*, "scale")= num 575000
1
The code works fine for me (I use Windows 7, R 3.3.1). Have you tried reinstalling the ggmap package?pe-perry
Yes, I did try that.karthikbharadwaj
What is your my.Map? Do you get something like 607x607 openstreetmap map image from OpenStreetMap. see ?ggmap to plot it. ?pe-perry
Yes I do see a raster imagekarthikbharadwaj
Works for me too. can you show the output of str(my.Map)?Ott Toomet

1 Answers

0
votes

The problem seems to be with Open Street Map (osm). ?get_openstreetmap will give you further details about the problem.

receive an error message from download.file with the message HTTP status '503 Service Unavailable'. You can confirm this by setting urlonly = TRUE, and then entering the URL in a web browser. the solution is either (1) change sources or (2) wait for the OSM servers to come back up.

If you change your code slightly to use google as the source it will work.

my.Map <- get_map(location ="Singapore",source = "google")
ggmap(my.Map)

Rendered from the code above