Younes
Younes

Reputation: 129

How to plot a large rasterfile quickly in R leaflet with shiny

I obtianed a large rasterfile (.asc file), which I can import in R and plot on a leaflet map. Because the file is pretty big, it takes about 40 seconds before the rasterimage is plotted on the basemap. This in comparison to shapefiles, which are plotted almost instantly.

I am wondering if there is a way to have the rasterfile plotted on the basemap more quickly?

The code I use to plot the file on the map is the following:

r = raster("file.asc")
 leaflet() %>% addSearchOSM() %>% 
  addProviderTiles(providers$CartoDB.Positron,
                   options = providerTileOptions(noWrap = TRUE),
                   group = "kaart") %>%
  addRasterImage(r, opacity = 0.5)

Upvotes: 1

Views: 1076

Answers (0)

Related Questions