Skip to content

Commit

Permalink
for #1596
Browse files Browse the repository at this point in the history
  • Loading branch information
rhijmans committed Nov 26, 2024
1 parent af61f2b commit d91c644
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 8 additions & 2 deletions R/plot_let.R
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ make.panel <- function(x, maxcell) {

setMethod("plet", signature(x="SpatRaster"),
function(x, y=1, col, alpha=0.8, main=names(x), tiles=c("Streets", "Esri.WorldImagery", "OpenTopoMap"),
wrap=TRUE, maxcell=500000, legend="bottomright", shared=FALSE, panel=FALSE, collapse=TRUE, map=NULL) {
wrap=TRUE, maxcell=500000, stretch=NULL, legend="bottomright", shared=FALSE, panel=FALSE, collapse=TRUE, map=NULL) {

#checkLeafLetVersion()

Expand Down Expand Up @@ -497,7 +497,6 @@ setMethod("plet", signature(x="SpatRaster"),

alpha <- max(0, min(1, alpha))

ny <- length(y)
hasRGB <- has.RGB(x)

if (hasRGB) {
Expand Down Expand Up @@ -550,6 +549,13 @@ setMethod("plet", signature(x="SpatRaster"),
}

if (hasRGB) {
if (!is.null(stretch)) {
if (stretch == "lin") {
x <- stretch(x, minq=0.02, maxq=0.98)
} else {
x <- stretch(x, histeq=TRUE, scale=255)
}
}
RGB(x) <- 1:length(y)
x <- colorize(x, "col")
}
Expand Down
6 changes: 4 additions & 2 deletions man/plet.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Plot the values of a SpatRaster or SpatVector to make an interactive leaflet map
\usage{
\S4method{plet}{SpatRaster}(x, y=1, col, alpha=0.8, main=names(x),
tiles=c("Streets", "Esri.WorldImagery", "OpenTopoMap"),
wrap=TRUE, maxcell=500000, legend="bottomright",
wrap=TRUE, maxcell=500000, stretch=NULL, legend="bottomright",
shared=FALSE, panel=FALSE, collapse=TRUE, map=NULL)


Expand Down Expand Up @@ -53,7 +53,9 @@ Plot the values of a SpatRaster or SpatVector to make an interactive leaflet map
\item{fill}{Number between 0 and 1 to set the transparency for polygon areas (0 is transparent, 1 is opaque)}
\item{tiles}{character or NULL. Names of background tile providers}
\item{wrap}{logical. if \code{TRUE}, tiles wrap around}
\item{maxcell}{positive integer. Maximum number of cells to use for the plot}
\item{maxcell}{positive integer. Maximum number of cells to use for the plot}
\item{stretch}{NULL or character ("lin" or "hist") to stretch RGB rasters. See \code{\link{plotRGB}}}

\item{legend}{character to indicate the legend position ("bottomleft", "bottomright", "topleft" or "topright") or NULL to suppress the legend}
\item{main}{character. Title for the legend. The length should be 1 if \code{x} is a SpatVector and length nlyr(x) if \code{x} is a SpatVector}

Expand Down

0 comments on commit d91c644

Please sign in to comment.