[R-sig-Geo] Cannot view custom tiles made in package tiler in r leaflet - either locally or from github pages server.

nevil amos nev||@@mo@ @end|ng |rom gm@||@com
Fri Feb 7 05:34:05 CET 2020


I wish to create tiled version of a large number of custom rasters for
viewing in shiny/leaflet apps ( to speed viewing of rasters)

I have produced tiles using  package tiler, these can be viewed in the
preview.html, but when uploaded to github pages  as described in the
introduction to tiler they do not show up when added as tiles in leaflet.

It is difficult to make a reproducible code here - since the tiles have to
be loaded to be served from the web.

However below I include the code used 1. to produce the tiles and 2, to
view the tiles in my github pages.

I have tried the suggestion of using {-y} in the sever path for TMS, this
makes no difference the background map is displayed but the custom tiles
are not.

Raster used from the package as an example in reality I need to serve many
10000x6000 cell geotiffs.

Example code:

library(tiler)
libary(leaflet)
# make tiles in zoom levels 1:6 these tiles have then been uploaded to
github to serve from repository:
#

tile_dir<-"us48lr"
map <- system.file("maps/map_wgs84.tif", package = "tiler")
tile(map,tile_dir , "0-6")
view_tiles(tile_dir)


#no TMS related modifications
tiles <- "https://nevilamos.github.io/TileTest/us48lr/{z}/{x}/{y}.png"
leaflet(
  options = leafletOptions(minZoom = 0, maxZoom = 7), width = "100%") %>%
  addProviderTiles("Stamen.Toner") %>%
  addTiles(urlTemplate=tiles, options = tileOptions(opacity = 0.8)) %>%
setView(-100, 40, 3)

#No tiles displayed


# {-y} and tileOptions(tms=T)
tiles <- "https://nevilamos.github.io/TileTest/us48lr/{z}/{x}/{-y}.png"
leaflet(
  options = leafletOptions(minZoom = 0, maxZoom = 7), width = "100%") %>%
  addProviderTiles("Stamen.Toner") %>%
  addTiles(urlTemplate=tiles, options = tileOptions(opacity = 0.8,tms=T))
%>% setView(-100, 40, 3)

#No tiles displayed

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list