Greetings, I have some raster data that is tiled and formatted for display in the Google Maps API:
https://storage.googleapis.com/flag_twi/flag_twi/index.html
Is there a way to access these tiles through R Leaflet?
I see in the leaflet documentation an argument for a URL:
addTiles(map, urlTemplate = "//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
attribution = NULL, layerId = NULL, group = NULL,
options = tileOptions())
...though it is not immediately apparent if this function will accept my tiles in the manner that they are currently indexed.
And relatedly, are there functions to tile raster data in a format that R leaflet can read? Basically searching for a more agile alternative to addRasterImage()
Have you tried your raster data in its current format with the code you posted? What format is the raster data in? Do you have access to it as a shapefile or the original shapefiles?
Yes, this particular raster is quite small, only a few megs, and loads fairly quickly when displayed as a raster image with the addRasterImage() function. I posted it merely as an example of the underlying javascript.
But I hope to display global extent data that is several gigs in its native format in a Shiny app, and I understand this far is beyond the capacity of addRasterImage(). The leaflet documentation advises against anything larger than 8 megs. The native format of the raster data is .tif, but the link I provided earlier is the product of a tiling process that has transformed these data into 256x256 pixel .pngs at various zoom levels, and indexed them such that they can be accessed in the Google Maps API. This process was conducted in Google Earth Engine, for those that are wondering, and I have no idea how that operation was performed.
I'm hoping that there is a way to to access these tiles in leaflet to rapidly display global high resolution imagery and at the same time benefit from the ease of interactivity provided in Shiny. Is there a way to do this with the addTiles() function in leaflet?
I don't have a detailed answer for you at this moment, but I know that leaflet is not designed to work with extremely large shapefiles and a file that big might be too large for effective use with leaflet. So I am not sure whether your issue is really with addRasterImage()
or with leaflet in general.
These Google tiles, I would expect, are analogous to the basemap provider tiles in leaflet. And my hope is that one could supply custom provider tiles in R leaflet.