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

qmplot not returning correct map type #281

Open
pconwell opened this issue May 1, 2019 · 13 comments
Open

qmplot not returning correct map type #281

pconwell opened this issue May 1, 2019 · 13 comments

Comments

@pconwell
Copy link

pconwell commented May 1, 2019

When using qmplot(), the maptype variable seems to be ignored. See the below example. maptype is set to toner-lite but it appears to be using terrain instead.

Probably unrelated, but for comparison, ggmap(get_stamenmap()) seems to work fine.

ggmap(get_stamenmap(c(left = -86.817417, bottom = 36.133247, right = -86.793141, top = 36.153650), zoom = 15, maptype = "toner-lines"))

Below is the example that gives an error. It should be toner-lite but it is downloading terrain instead. I tried toner as well, but it gave the same results.

library(ggmap)
#> Loading required package: ggplot2
#> Registered S3 methods overwritten by 'ggplot2':
#>   method         from 
#>   [.quosures     rlang
#>   c.quosures     rlang
#>   print.quosures rlang
#> Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
#> Please cite ggmap if you use it! See citation("ggmap") for details.
test <- data.frame('id' = c('0001','0002','0003'), 'latitude' = c(36.11768, 36.15525, 36.12812), 'longitude' = c(-86.72005, -86.73721, -86.77464))
qmplot(longitude, latitude, data = test, maptype = "toner-lite", color = I("red"))
#> Using zoom = 14...
#> Source : http://tile.stamen.com/terrain/14/4242/6424.png
#> Source : http://tile.stamen.com/terrain/14/4243/6424.png
#> Source : http://tile.stamen.com/terrain/14/4244/6424.png
#> Source : http://tile.stamen.com/terrain/14/4245/6424.png
#> Source : http://tile.stamen.com/terrain/14/4242/6425.png
#> Source : http://tile.stamen.com/terrain/14/4243/6425.png
#> Source : http://tile.stamen.com/terrain/14/4244/6425.png
#> Source : http://tile.stamen.com/terrain/14/4245/6425.png
#> Source : http://tile.stamen.com/terrain/14/4242/6426.png
#> Source : http://tile.stamen.com/terrain/14/4243/6426.png
#> Source : http://tile.stamen.com/terrain/14/4244/6426.png
#> Source : http://tile.stamen.com/terrain/14/4245/6426.png
#> Source : http://tile.stamen.com/terrain/14/4242/6427.png
#> Source : http://tile.stamen.com/terrain/14/4243/6427.png
#> Source : http://tile.stamen.com/terrain/14/4244/6427.png
#> Source : http://tile.stamen.com/terrain/14/4245/6427.png

Created on 2019-05-01 by the reprex package (v0.2.1)

Session info
sessionInfo()
#> R version 3.6.0 (2019-04-26)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 17134)
#> 
#> Matrix products: default
#> 
#> locale:
#> [1] LC_COLLATE=English_United States.1252 
#> [2] LC_CTYPE=English_United States.1252   
#> [3] LC_MONETARY=English_United States.1252
#> [4] LC_NUMERIC=C                          
#> [5] LC_TIME=English_United States.1252    
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] ggmap_3.0.0   ggplot2_3.1.1
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.1        pillar_1.3.1      compiler_3.6.0   
#>  [4] plyr_1.8.4        highr_0.8         bitops_1.0-6     
#>  [7] tools_3.6.0       digest_0.6.18     evaluate_0.13    
#> [10] tibble_2.1.1      gtable_0.3.0      pkgconfig_2.0.2  
#> [13] png_0.1-7         rlang_0.3.4       curl_3.3         
#> [16] yaml_2.2.0        xfun_0.6          xml2_1.2.0       
#> [19] withr_2.1.2       dplyr_0.8.0.1     stringr_1.4.0    
#> [22] httr_1.4.0        knitr_1.22        RgoogleMaps_1.4.3
#> [25] grid_3.6.0        tidyselect_0.2.5  glue_1.3.1       
#> [28] R6_2.4.0          jpeg_0.1-8        rmarkdown_1.12   
#> [31] tidyr_0.8.3       purrr_0.3.2       magrittr_1.5     
#> [34] scales_1.0.0      htmltools_0.3.6   assertthat_0.2.1 
#> [37] mime_0.6          colorspace_1.4-1  labeling_0.3     
#> [40] stringi_1.4.3     lazyeval_0.2.2    munsell_0.5.0    
#> [43] rjson_0.2.20      crayon_1.3.4
@DinRigtigeFar
Copy link

When using qmplot(), the maptype variable seems to be ignored. See the below example. maptype is set to toner-lite but it appears to be using terrain instead.

Probably unrelated, but for comparison, ggmap(get_stamenmap()) seems to work fine.

ggmap(get_stamenmap(c(left = -86.817417, bottom = 36.133247, right = -86.793141, top = 36.153650), zoom = 15, maptype = "toner-lines"))

Below is the example that gives an error. It should be toner-lite but it is downloading terrain instead. I tried toner as well, but it gave the same results.

library(ggmap)
#> Loading required package: ggplot2
#> Registered S3 methods overwritten by 'ggplot2':
#>   method         from 
#>   [.quosures     rlang
#>   c.quosures     rlang
#>   print.quosures rlang
#> Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
#> Please cite ggmap if you use it! See citation("ggmap") for details.
test <- data.frame('id' = c('0001','0002','0003'), 'latitude' = c(36.11768, 36.15525, 36.12812), 'longitude' = c(-86.72005, -86.73721, -86.77464))
qmplot(longitude, latitude, data = test, maptype = "toner-lite", color = I("red"))
#> Using zoom = 14...
#> Source : http://tile.stamen.com/terrain/14/4242/6424.png
#> Source : http://tile.stamen.com/terrain/14/4243/6424.png
#> Source : http://tile.stamen.com/terrain/14/4244/6424.png
#> Source : http://tile.stamen.com/terrain/14/4245/6424.png
#> Source : http://tile.stamen.com/terrain/14/4242/6425.png
#> Source : http://tile.stamen.com/terrain/14/4243/6425.png
#> Source : http://tile.stamen.com/terrain/14/4244/6425.png
#> Source : http://tile.stamen.com/terrain/14/4245/6425.png
#> Source : http://tile.stamen.com/terrain/14/4242/6426.png
#> Source : http://tile.stamen.com/terrain/14/4243/6426.png
#> Source : http://tile.stamen.com/terrain/14/4244/6426.png
#> Source : http://tile.stamen.com/terrain/14/4245/6426.png
#> Source : http://tile.stamen.com/terrain/14/4242/6427.png
#> Source : http://tile.stamen.com/terrain/14/4243/6427.png
#> Source : http://tile.stamen.com/terrain/14/4244/6427.png
#> Source : http://tile.stamen.com/terrain/14/4245/6427.png

Created on 2019-05-01 by the reprex package (v0.2.1)

Session info

sessionInfo()
#> R version 3.6.0 (2019-04-26)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 17134)
#> 
#> Matrix products: default
#> 
#> locale:
#> [1] LC_COLLATE=English_United States.1252 
#> [2] LC_CTYPE=English_United States.1252   
#> [3] LC_MONETARY=English_United States.1252
#> [4] LC_NUMERIC=C                          
#> [5] LC_TIME=English_United States.1252    
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] ggmap_3.0.0   ggplot2_3.1.1
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.1        pillar_1.3.1      compiler_3.6.0   
#>  [4] plyr_1.8.4        highr_0.8         bitops_1.0-6     
#>  [7] tools_3.6.0       digest_0.6.18     evaluate_0.13    
#> [10] tibble_2.1.1      gtable_0.3.0      pkgconfig_2.0.2  
#> [13] png_0.1-7         rlang_0.3.4       curl_3.3         
#> [16] yaml_2.2.0        xfun_0.6          xml2_1.2.0       
#> [19] withr_2.1.2       dplyr_0.8.0.1     stringr_1.4.0    
#> [22] httr_1.4.0        knitr_1.22        RgoogleMaps_1.4.3
#> [25] grid_3.6.0        tidyselect_0.2.5  glue_1.3.1       
#> [28] R6_2.4.0          jpeg_0.1-8        rmarkdown_1.12   
#> [31] tidyr_0.8.3       purrr_0.3.2       magrittr_1.5     
#> [34] scales_1.0.0      htmltools_0.3.6   assertthat_0.2.1 
#> [37] mime_0.6          colorspace_1.4-1  labeling_0.3     
#> [40] stringi_1.4.3     lazyeval_0.2.2    munsell_0.5.0    
#> [43] rjson_0.2.20      crayon_1.3.4

I have the same problem. I always get terrain instead of the supplied maptype.

@fbertran
Copy link

Same problem here too.

@NateMietk
Copy link

here too

@jesseflamb
Copy link

same for me as well

@dvictori
Copy link

I'm having the same issue when using get_map

br_sul <- get_map(sul, maptype = "toner-lite", source = 'stamen', force = TRUE)
Source : http://tile.stamen.com/terrain/5/10/17.png
Source : http://tile.stamen.com/terrain/5/11/17.png
Source : http://tile.stamen.com/terrain/5/12/17.png
Source : http://tile.stamen.com/terrain/5/13/17.png
Source : http://tile.stamen.com/terrain/5/10/18.png
Source : http://tile.stamen.com/terrain/5/11/18.png
Source : http://tile.stamen.com/terrain/5/12/18.png
Source : http://tile.stamen.com/terrain/5/13/18.png
Source : http://tile.stamen.com/terrain/5/10/19.png
Source : http://tile.stamen.com/terrain/5/11/19.png
Source : http://tile.stamen.com/terrain/5/12/19.png
Source : http://tile.stamen.com/terrain/5/13/19.png

@kpanthagani
Copy link

same issue. found a workaround with get_stamenmap()

@pconwell
Copy link
Author

@kpanthagani , What's the work-around?

@kpanthagani
Copy link

enter the latitude and longitude of the boundaries of the map you want (example for Houston, TX)
mapboundaries <- c(left = -95.75, right = -94.9, top = 30.1, bottom = 29.5)

get stamenmap
notterrain <- get_stamenmap(bbox = mapboundaries, zoom = 10, maptype = "toner")

plot your data on it
coolmap <- ggmap(notterrain) + geom_point(data = mydata, aes(x = lon, y = lat))
plot(coolmap)

@bbolker
Copy link

bbolker commented Nov 28, 2019

this appears to be the same as #287 ; I have diagnosed the problem here (and it appears to be fixed in the development version ...)

@csdiehl
Copy link

csdiehl commented Jan 2, 2020

Has anybody found an answer to this question? I'm getting the same problem.

@pconwell
Copy link
Author

pconwell commented Jan 2, 2020

@kpanthagani @bbolker does this solution also apply to qmplot? I have not had issue with setting the map boundaries manually and calling ggmap(). The issue I am seeing is when calling the map through qmplot(). For example:

library(ggmap)
test <- data.frame('id' = c('0001','0002','0003'), 'latitude' = c(36.11768, 36.15525, 36.12812), 'longitude' = c(-86.72005, -86.73721, -86.77464))
qmplot(longitude, latitude, data = test, maptype = "toner-lite", color = I("red"))

@kpanthagani
Copy link

@pconwell no my workaround (using get_stamenmap) doesn't work with qmplot. I believe the bug is in get_map() and was fixed in the development version of ggmap as @bbolker referenced, though I haven't checked that out myself.

@pconwell
Copy link
Author

pconwell commented Jan 2, 2020

@kpanthagani User error on my end, I forgot to reload the library after installing from github. The current master branch (at least as of 37a8672) is working correctly. The bug appears to have been introduced in 771a71b and fixed in 12d4678 (as stated by @bbolker).

@csdiehl, if you follow @bbolker's recommendations, it will work. The below steps are probably overkill, but it will make sure that the library is reloaded.

detach("package:ggmap")
remove.packages("ggmap")

devtools::install_github("dkahle/ggmap")

.rs.restartR()
library(ggmap)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants