0

Unfortunately, I struggle to show a reproducible example here. The issue occurs only, when I add a locally saved raster file (140mb) to a leaflet map. And I don't know how to share such a large file here. The map shows fine in the rStudio viewer and in Chrome. But it fails to show the raster in Firefox and Safari (Firefox on OSX and iOS). Even auto zoom and pan does not work.

When I add a system raster file, everything works as expected:

library(leaflet)
library(leafem)
library(raster)
library(stars) #to access the stars system.file

tif = system.file("tif/L7_ETMs.tif", package = "stars")
x2 <- raster(tif)

map_raster <- leaflet() %>%
  addTiles() %>%
  leafem:::addGeoRaster(
    x2, 
    opacity = 1,
    colorOptions = colorOptions(
      palette = grey.colors(256)
    )
  )

library(htmlwidgets)
saveWidget(map_raster, file = "TestExport_raster.html", selfcontained = T)

But when I replace x2 with the local raster, it does not work. Tried adding an object from the raster and the stars package, but with no difference.

Any help on that? Is the raster just too big for a leaflet-map?

The question might be related to this one: saving R leaflet map as html: tiles not included

Best, Beni

Beni
  • 66
  • 4

0 Answers0