SpatRaster layers as an interactive leaflet map with a sliderR/studyAreaPlotting.R
plotTimeSeriesLeaflet.RdTakes a multi-layer SpatRaster (or a list of single-layer SpatRasters)
and produces a self-contained leaflet htmlwidget. Each layer becomes a
radio-selected base group; a draggable range slider is added that drives
the radio buttons, so the user steps through years by dragging.
plotTimeSeriesLeaflet(
x,
palette = "viridis",
rev = FALSE,
layerName = "raster",
sliderPosition = "bottomleft",
legendPosition = "bottomright"
)One of:
a multi-layer SpatRaster – becomes one "object" named "raster"
a list of single-layer SpatRasters – same
a simList – reads ALL <obj>*.tif time-series from
SpaDES.core::outputPath(x)
a length-1 character path to a directory of GeoTIFFs – same scan
For the disk-scan cases, files are grouped by base name (last regex match = time tag) into separate "objects". Each object becomes a radio-selectable layer in the UI.
Palette name. Default "viridis". Tried first with
terra::map.pal(), falling back to grDevices::hcl.colors().
Reverse the palette? Default FALSE.
Short prefix used for each per-layer GeoTIFF filename (avoids collisions when multiple time-series sit on the same page).
Leaflet control position for the object-radio +
year-slider UI: "bottomleft" (default), "bottomright",
"topleft", "topright".
Leaflet control position for the per-object
colour legend. Default "bottomright".
A leaflet htmlwidget with the slider injected via
htmlwidgets::onRender(). Ships as static HTML – no Shiny server needed.
Designed to ship in a Quarto / knitr static render – uses
.leafletGeoTiffPath() internally so the per-layer GeoTIFFs are written
into the qmd's _files/figure-html/ folder rather than tempfile().
plotSAsLeaflet() for the single-snapshot case.