
Add stars layer to a leaflet map
addStarsImage(map, x, colors = "Spectral", opacity = 1,
attribution = NULL, layerId = NULL, group = NULL, project = FALSE,
method = c("bilinear", "ngb"), maxBytes = 4 * 1024 * 1024)
a mapview or leaflet object.
a stars layer
the color palette (see colorNumeric) or function to use to color the raster values (hint: if providing a function, set na.color to "#00000000" to make NA areas transparent)
the base opacity of the raster, expressed from 0 to 1
the HTML string to show as the attribution for this layer
the layer id
the name of the group this raster image should belong to (see the same parameter under addTiles)
if TRUE, automatically project x to the map projection expected by Leaflet (EPSG:3857); if FALSE, it's the caller's responsibility to ensure that x is already projected, and that extent(x) is expressed in WGS84 latitude/longitude coordinates
the method used for computing values of the new, projected raster image. "bilinear" (the default) is appropriate for continuous data, "ngb" - nearest neighbor - is appropriate for categorical data. Ignored if project = FALSE. See projectRaster for details.
the maximum number of bytes to allow for the projected image (before base64 encoding); defaults to 4MB.
This is an adaption of addRasterImage
. See that documentation
for details.
# NOT RUN {
library(stars)
library(leaflet)
tif = system.file("tif/L7_ETMs.tif", package = "stars")
x = st_stars(tif)
leaflet() %>%
addProviderTiles("OpenStreetMap") %>%
addStarsImage(x)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab