Learn R Programming

terra (version 1.7-29)

plet: Plot with leaflet

Description

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").

Usage

# 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, ...)

Arguments

x

SpatRaster, SpatVector, or leaflet object

y

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

col

character. Vector of colors or color generating function

alpha

Number between 0 and 1 to set the transparency for lines (0 is transparent, 1 is opaque)

fill

Number between 0 and 1 to set the transparency for polygon areas (0 is transparent, 1 is opaque)

tiles

character or NULL. Names of background tile providers

wrap

logical. if TRUE, tiles wrap around

maxcell

positive integer. Maximum number of cells to use for the plot

legend

character to indicate the legend position ("bottomleft", "bottomright", "topleft" or "topright") or NULL to suppress the legend

main

character. Title for the legend. The length should be 1 if x is a SpatVector and length nlyr(x) if x is a SpatVector

shared

logical. Should the legend be the same for all rasters (if multiple layers of SpatRaster x are mapped)

map

leaflet object

...

additional arguments for drawing points, lines, or polygons passed on the the relevant leaflet function

collapse

logical. Should the layers "control" panel be collapsed?

split

logical. IF TRUE a check-box is created to toggle each value in codey (If x is a SpatVector)

cex

numeric. point size magnifier. See par

lwd

numeric, line-width. See par

popup

logical. Should pop-ups be created?

label

logical. Should mouse-over labels be added?

panel

logical. Should SpatRaster layers be shown as a panel"

See Also