Elaine Hale
Elaine Hale

Reputation: 1488

Why is my attempt to use the latest ggmap and R producing a blank map on Windows?

The following two lines of code:

map = get_map()
ggmap(map)

Downloads a ggmapTemp.png:

google map saved to disk

But produces the following plot:

blank ggplot that should be showing the saved map

Why is the successfully saved google map png not getting incorporated into the final ggplot? This is working for us on Mac.

The environment:

sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)

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

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

other attached packages:
 [1] mapproj_1.2-2        maps_2.3-6           gdxrrw_0.4.0         rMaps_0.1.1         
 [5] shinyIncubator_0.2.1 rCharts_0.4.5        gridExtra_0.9.1      rgeos_0.3-6         
 [9] knitr_1.6            ggmap_2.3            rgdal_0.8-16         sp_1.0-15           
[13] stringr_0.6.2        shiny_0.9.1          scales_0.2.3         RPostgreSQL_0.4     
[17] DBI_0.2-7            reshape2_1.2.2       RColorBrewer_1.0-5   plyr_1.8.1          
[21] ggplot2_0.9.3.1      gdata_2.13.3         devtools_1.5        

loaded via a namespace (and not attached):
 [1] bitops_1.0-6        caTools_1.16        colorspace_1.2-4    dichromat_2.0-0     digest_0.6.4       
 [6] evaluate_0.5.3      formatR_0.10        gtable_0.1.2        gtools_3.4.1        httpuv_1.3.0       
[11] httr_0.3            labeling_0.2        lattice_0.20-29     MASS_7.3-35         memoise_0.1        
[16] munsell_0.4.2       parallel_3.1.2      png_0.1-7           proto_0.3-10        Rcpp_0.11.1        
[21] RCurl_1.95-4.1      RgoogleMaps_1.2.0.6 rjson_0.2.14        RJSONIO_1.0-3       tools_3.1.2        
[26] whisker_0.3-2       xtable_1.7-3        yaml_2.1.11   

Upvotes: 1

Views: 318

Answers (1)

clayton barrows
clayton barrows

Reputation: 26

I had the same problem (blank figures from ggmap()), I tried the suggestions from Serban with no luck. I was able to generate figures using a different plotting device:

map=get_map()
bmp('map.bmp')
ggmap(map)
dev.off()

Other devices work as well (tiff, pdf, svg...)

Upvotes: 1

Related Questions