4

I am wanting to use the addRasterImage() function to a leaflet object in R.

However it only seems to work up-to a zoom level of 18. Please see the example below.

 library(raster)
 library(leaflet)
 library(magrittr)

 r <- raster(xmn=-2.8, xmx=-2.79, ymn=54.04, ymx=54.05, nrows=30, ncols=30)
 values(r) <- matrix(1:900, nrow(r), ncol(r), byrow = TRUE)
 crs(r) <- CRS("+init=epsg:4326")

 leaflet() %>% addTiles() %>%
   setView(lat=54.045,lng=-2.795,zoom=19) %>%
   addRasterImage(r, colors = "Spectral", opacity = 0.8)

I know that the addTiles() function naturally only shows tiles up to a zoom of 18, but I was assuming that the raster image should still show at the higher zoom level. Furthermore, there are other tile providers (e.g. HERE) that do have zoom levels that go higher than 18, but the issue with the lack of the Raster image on the leaflet object still persists.

Any help would be greatly appreciated.

IvanSanchez
  • 18,272
  • 3
  • 30
  • 45
h.l.m
  • 13,015
  • 22
  • 82
  • 169
  • "I know that the addTiles() function naturally only shows tiles up to a zoom of 18"... where is that documented? – serv-inc Jun 15 '17 at 15:19
  • 1
    Apologies i think it might actually have a max zoom of 19 as seen here http://leaflet-extras.github.io/leaflet-providers/preview/index.html – h.l.m Jun 16 '17 at 08:18
  • No apologies needed. So does this solve the question, as in "the tiles do not exist at all" (as of http://wiki.openstreetmap.org/wiki/Zoom_levels, the maximum zoom level is 19), or do you wish to use higher-zoom tiles (possible as of http://wiki.openstreetmap.org/wiki/User:SomeoneElse/Tileserver_zoom_levels)? – serv-inc Jun 16 '17 at 08:21
  • 1
    The issue is not with the tiles but more that the raster doesn't show at that zoom level – h.l.m Jun 16 '17 at 09:36

0 Answers0