Prepare an SpatRaster
object to be analyzed in pliman. This includes
cropping the original mosaic, aligning it, and cropping the aligned object.
The resulting object is an object of class Image
that can be further
analyzed.
Usage
mosaic_prepare(
mosaic,
r = 3,
g = 2,
b = 1,
re = 4,
nir = 5,
crop_mosaic = TRUE,
align = TRUE,
crop_aligned = TRUE,
rescale = TRUE,
coef = 0,
viewer = "mapview",
max_pixels = 5e+05,
show = "rgb",
index = "R"
)
Arguments
- mosaic
A mosaic of class
SpatRaster
, generally imported withmosaic_input()
.- r, g, b, re, nir
The red, green, blue, red-edge, and near-infrared bands of the image, respectively. By default, the function assumes a BGR as input (b = 1, g = 2, r = 3). If a multispectral image is provided up to seven bands can be used to compute built-in indexes. There are no limitation of band numbers if the index is computed using the band name.
- crop_mosaic
Logical, whether to crop the mosaic interactively before aligning it (default: FALSE).
- align
Logical, whether to align the mosaic interactively (default: TRUE).
- crop_aligned
Logical, whether to crop the aligned mosaic interactively (default: TRUE).
- rescale
Rescale the final values? If
TRUE
the final values are rescaled so that the maximum value is 1.- coef
An addition coefficient applied to the resulting object. This is useful to adjust the brightness of the final image. Defaults to 0.
- 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.- max_pixels
Maximum number of pixels to render in the map or plot (default: 500000).
- 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".
Examples
if (interactive() && requireNamespace("EBImage")) {
library(pliman)
mosaic <- mosaic_input(system.file("ex/elev.tif", package="terra"))
mosaic_prepare(mosaic)
}
#> 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
#>
#> Listening on http://127.0.0.1:6534
#> Error in st_bbox.default(x): no st_bbox method available for object of class NULL