I'm working with the ESA's landcover raster layer and ultimately want to display that data for the globe in a Leaflet Shiny app. Rendering such a massive file is impossible, so I've decided to create map tiles to display the data.
Creating the tiles was simple--I used the gdal2tiles
tool in QGIS. Here's a quick look of the output, which is in a local directory on my computer:
When I click the leaflet.html file
, the tiles are rendered in my browser, like so:
Obviously the tiles are in working order. The problem is that I don't know how to render these tiles in Leaflet for R. I tried following this tutorial, but nothing is rendered when I altered my code to fit the example. I also explored answers from this StackOverflow question, but all of the answers seem several years out of date.
Here's the R code that I'm using to try to get the tiles to render in any way:
library(leaflet)
leaflet() %>%
setView(0, 0, zoom = 1) %>%
addTiles(urlTemplate = "http://my-username.github.io/tiles/{z}/{x}/{y}.png",
options = tileOptions(minZoom = 1, maxZoom = 2, tms = TRUE)) %>%
addCircles(lat = 0, lng = 0, radius = 100) #just to see if anything is rendering
This code renders the circle I've drawn, but nothing else.
Is there a way to render these tiles directly from my local machine? If not, how do I host these tiles so that they can be rendered in Leaflet for R? It seems like this should be pretty straightforward, but I can't figure it out!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…