Skip to contents

Mosaic View

Usage

mosaic_view(
  mosaic,
  r = 3,
  g = 2,
  b = 1,
  re = 4,
  nir = 5,
  edit = FALSE,
  title = "",
  viewer = c("mapview", "base"),
  show = c("rgb", "index"),
  index = "B",
  max_pixels = 1e+06,
  downsample = NULL,
  alpha = 1,
  quantiles = c(0, 1),
  domain = NULL,
  color_regions = custom_palette(),
  axes = FALSE,
  ...
)

Arguments

mosaic

A mosaic of class SpatRaster, generally imported with mosaic_input().

r

The layer for the Red band (default: 3).

g

The layer for the Green band (default: 2).

b

The layer for the Blue band (default: 1).

re

The layer for the Red-edge band (default: 4).

nir

The layer for the Near-infrared band(default: 5).

edit

If TRUE enable editing options using mapedit::editMap().

title

A title for the generated map or plot (default: "").

viewer

The viewer option. If not provided, the value is retrieved using get_pliman_viewer(). This option controls the type of viewer to use for interactive plotting. The available options are "base" and "mapview". If set to "base", the base R graphics system is used for interactive plotting. If set to "mapview", the mapview package is used. To set this argument globally for all functions in the package, you can use the set_pliman_viewer() function. For example, you can run set_pliman_viewer("mapview") to set the viewer option to "mapview" for all functions.

show

The display option for the map view. Options are "rgb" for RGB view and "index" for index view.

index

The index to use for the index view. Defaults to "B".

max_pixels

Maximum number of pixels to render in the map or plot (default: 500000).

downsample

Downsampling factor to reduce the number of pixels (default: NULL). In this case, if the number of pixels in the image (width x height) is greater than max_pixels a downsampling factor will be automatically chosen so that the number of plotted pixels approximates the max_pixels.

alpha

opacity of the fill color of the raster layer(s).

quantiles

the upper and lower quantiles used for color stretching. If set to NULL, stretching is performed basing on 'domain' argument.

domain

the upper and lower values used for color stretching. This is used only if 'quantiles' is NULL. If both 'domain' and 'quantiles' are set to NULL, stretching is applied based on min-max values.

color_regions

The color palette for displaying index values. Default is custom_palette().

axes

logical. Draw axes? Defaults to FALSE.

...

Additional arguments passed on to terra::plot() when viewer = "base".

Value

An sf object, the same object returned by mapedit::editMap().

Details

The function can generate either an interactive map using the 'mapview' package or a static plot using the 'base' package, depending on the viewer and show parameters. If show = "index" is used, the function first computes an image index that can be either an RGB-based index or a multispectral index, if a multispectral mosaic is provided.

Examples

if(interactive()){
library(pliman)
# Load a raster showing the elevation of Luxembourg
mosaic <- mosaic_input(system.file("ex/elev.tif", package="terra"))

# Generate an interactive map using 'mapview'
mosaic_view(mosaic)

# Generate a static plot using 'base'
mosaic_view(mosaic, viewer = "base")
}