if (interactive()) {
library(leaflet)
library(leafem)
library(stars)
tif = system.file("tif/L7_ETMs.tif", package = "stars")
x1 = read_stars(tif)
x1 = x1[, , , 3] # band 3
tmpfl = tempfile(fileext = ".tif")
write_stars(st_warp(x1, crs = 4326), tmpfl)
leaflet() %>%
addTiles() %>%
addGeotiff(
file = tmpfl
, opacity = 0.9
, colorOptions = colorOptions(
palette = hcl.colors(256, palette = "inferno")
, na.color = "transparent"
)
)
}
Run the code above in your browser using DataLab