dkahle / ggmap

A package for plotting maps in R with ggplot2
766 stars 231 forks source link

stamen_watercolor doesn't work #361

Open rssco opened 5 months ago

rssco commented 5 months ago

Hi, I am working with get_stadiamap and I would like to have the "stamen_watercolor" maptype. However, I get this error with the basic usage :

bbox <- c(left = 24.61, bottom = 59.37, right = 24.94, top = 59.5) get_stadiamap(bbox, zoom = 12, maptype = "stamen_watercolor") %>% ggmap()

ℹ © Stadia Maps © Stamen Design © OpenMapTiles © OpenStreetMap contributors. Error: ! Failed to evaluate glue component {filetype} Caused by error: ! object 'filetype' not found Backtrace:

  1. ... %>% ggmap()
  2. ggmap::get_stadiamap(bbox, zoom = 12, maptype = "stamen_watercolor")
  3. base::lapply(...)
  4. ggmap (local) FUN(X[[i]], ...)
  5. ggmap:::get_stadiamap_tile(...)

All maptypes work except the stamen_watercolor. Any help with this would be highly appreciated :)

Thanks! Coralie

andrew-griffen commented 5 months ago

I had same issue but got the stamen_watercolor to work by installing from github using devtools::install_github("dkahle/ggmap"). Not sure why package version on CRAN is giving that error.

LuisLauM commented 5 months ago

Hi, I am working with get_stadiamap and I would like to have the "stamen_watercolor" maptype. However, I get this error with the basic usage :

bbox <- c(left = 24.61, bottom = 59.37, right = 24.94, top = 59.5) get_stadiamap(bbox, zoom = 12, maptype = "stamen_watercolor") %>% ggmap()

ℹ © Stadia Maps © Stamen Design © OpenMapTiles © OpenStreetMap contributors. Error: ! Failed to evaluate glue component {filetype} Caused by error: ! object 'filetype' not found Backtrace:

  1. ... %>% ggmap()
  2. ggmap::get_stadiamap(bbox, zoom = 12, maptype = "stamen_watercolor")
  3. base::lapply(...)
  4. ggmap (local) FUN(X[[i]], ...)
  5. ggmap:::get_stadiamap_tile(...)

All maptypes work except the stamen_watercolor. Any help with this would be highly appreciated :)

Thanks! Coralie

Hello.

The problem comes from two sides:

Possible (temporary) solutions:

I have opted for the second option and so far it is working for me. Of course, in those maps where there are empty tiles, graphics like this will be generated:

image

You can see that in the upper right corner there are white squares (that's because there are tiles there that are not available and that ggmap covers them with a white square).

Note: If you are not very familiar with compiling R packages, you can use the fork I have made (patched and temporarily functional) and re-install ggmap from that forked version (running remotes::install_github("LuisLauM/ggmap", force = TRUE)), but I will delete it as soon as the ggmap authors commit it and fix the problem properly.

https://github.com/LuisLauM/ggmap

mkierczak commented 3 months ago

I believe the problem lies in ggmap:::get_stamen_url and if (maptype %in% c("watercolor")) should be if (maptype %in% c("stamen_watercolor")) Partial matching does not apply here and current version of the if-then clause leads to wrong file extension for stamen_watercolor.

Tested and it actually fixes the issue.

rssco commented 2 months ago

Thanks to everyone, the problem is solved with @andrew-griffen's solution ! :)