Mosaic View
Usage
mosaic_view(
mosaic,
r = 3,
g = 2,
b = 1,
edit = FALSE,
title = "",
shapefile = NULL,
attribute = NULL,
viewer = c("mapview", "base"),
show = c("rgb", "index"),
index = "B",
max_pixels = 1e+06,
downsample = NULL,
downsample_fun = "nearest",
alpha = 1,
quantiles = c(0, 1),
color_regions = custom_palette(c("red", "yellow", "forestgreen")),
axes = FALSE,
...
)
Arguments
- mosaic
A mosaic of class
SpatRaster
, generally imported withmosaic_input()
.- r, g, b
The layer for the Red, Green and Blue band, respectively. Defaults to
1
,2
, and3
.- edit
If
TRUE
enable editing options usingmapedit::editMap()
.- title
A title for the generated map or plot (default: "").
- shapefile
An optional shapefile of class
sf
to be plotted over the mosaic. It can be, for example, a plot-level result returned bymosaic_analyze()
.- attribute
The attribute name(s) or column number(s) in shapefile table of the column(s) to be rendered.
- 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 theset_pliman_viewer()
function. For example, you can runset_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 themax_pixels
.- downsample_fun
The resampling function. Defaults to nearest. See further details in
mosaic_aggregate()
.- alpha
opacity of the fill color of the raster layer(s).
- quantiles
the upper and lower quantiles used for color stretching.
- 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()
whenviewer = "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() && requireNamespace("EBImage")) {
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")
}
#> Warning: The current raster is in the lat/lon coordinate system, which may result in processing errors when trying to segment individuals in the `mosaic_analyze()` function. It is highly suggested to reproject the raster using mosaic_project() with EPSG:32632
#> class : SpatRaster
#> dimensions : 90, 95, 1 (nrow, ncol, nlyr)
#> resolution : 0.008333333, 0.008333333 (x, y)
#> extent : 5.741667, 6.533333, 49.44167, 50.19167 (xmin, xmax, ymin, ymax)
#> coord. ref. : lon/lat WGS 84 (EPSG:4326)
#> source : elev.tif
#> name : elevation
#> min value : 141
#> max value : 547