Learn R Programming

pliman (version 3.1.0)

mosaic_to_pliman: Mosaic to pliman

Description

Convert an SpatRaster object to a Image object with optional scaling.

Usage

mosaic_to_pliman(
  mosaic,
  r = 3,
  g = 2,
  b = 1,
  re = 4,
  nir = 5,
  rescale = TRUE,
  coef = 0
)

Value

An Image object with the same number of layers as mosaic.

Arguments

mosaic

A mosaic of class SpatRaster, generally imported with mosaic_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.

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.

Details

This function converts SpatRaster into an Image object, which can be used for image analysis in pliman. Note that if a large SpatRaster is loaded, the resulting object may increase considerably the memory usage.

Examples

Run this code
if (interactive() && requireNamespace("EBImage")) {
library(pliman)
# Convert a mosaic raster to an Image object
mosaic <- mosaic_input(system.file("ex/elev.tif", package="terra"))
pliman_image <- mosaic_to_pliman(mosaic)
plot(pliman_image)
}

Run the code above in your browser using DataLab