TransWikia.com

Plot "large" raster with leaflet in R

Geographic Information Systems Asked on May 17, 2021

I have a geotiff that is around 26MB on my hard drive. I would like to use leaflet to plot it within a shiny application.
However, it just doesn’t load. When I use mapview just to plot it locally it also takes some seconds, but eventually it will be plotted. To my knowledge it’s better to use leaflet in a shiny-app. So I don’t know exactly what to do now.

Here is some code, that produces a raster of more or less similar size

r = raster()
res(r) = 0.1
r[] = runif(ncell(r)) 

# plot it with mapview
mapview::mapview(r)

# plot it with leaflet
leaflet() %>% addTiles() %>% addRasterImage(r)


Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP