Plot the values of a SpatRaster or SpatVector to make an interactive leaflet map that is displayed in a browser.
These methods require the development version of leaflet that you can install with remotes::install_github("rstudio/leaflet")
.
# S4 method for SpatRaster
plet(x, y=1, col, alpha=0.8, main=names(x), tiles=NULL,
wrap=TRUE, maxcell=500000, legend="bottomright",
shared=FALSE, panel=FALSE, collapse=TRUE, map=NULL)
# S4 method for SpatVector
plet(x, y="", col, alpha=1, fill=0, main=y, cex=1, lwd=2, popup=TRUE,
label=FALSE, split=FALSE, tiles=c("Streets", "Esri.WorldImagery", "OpenTopoMap"),
wrap=TRUE, legend="bottomright", collapse=FALSE, map=NULL, ...)
# S4 method for SpatVectorCollection
plet(x, col, alpha=1, fill=0, cex=1, lwd=2, popup=TRUE,
label=FALSE, tiles=c("Streets", "Esri.WorldImagery", "OpenTopoMap"), wrap=TRUE,
legend="bottomright", collapse=FALSE, map=NULL)
# S4 method for leaflet
lines(x, y, col, lwd=2, alpha=1, ...)
# S4 method for leaflet
points(x, y, col, cex=1, alpha=1, popup=FALSE, ...)
SpatRaster, SpatVector, or leaflet object
missing, or positive integer, or character (variable or layer name) indicating the layer(s) to be plotted. If x
is a SpatRater, you can select multiple layers
character. Vector of colors or color generating function
Number between 0 and 1 to set the transparency for lines (0 is transparent, 1 is opaque)
Number between 0 and 1 to set the transparency for polygon areas (0 is transparent, 1 is opaque)
character or NULL. Names of background tile providers
logical. if TRUE
, tiles wrap around
positive integer. Maximum number of cells to use for the plot
character to indicate the legend position ("bottomleft", "bottomright", "topleft" or "topright") or NULL to suppress the legend
character. Title for the legend. The length should be 1 if x
is a SpatVector and length nlyr(x) if x
is a SpatVector
logical. Should the legend be the same for all rasters (if multiple layers of SpatRaster x
are mapped)
leaflet object
additional arguments for drawing points, lines, or polygons passed on the the relevant leaflet function
logical. Should the layers "control" panel be collapsed?
logical. IF TRUE
a check-box is created to toggle each value in codey (If x
is a SpatVector)
numeric. point size magnifier. See par
numeric, line-width. See par
logical. Should pop-ups be created?
logical. Should mouse-over labels be added?
logical. Should SpatRaster layers be shown as a panel"