Skip to contents

High-resolution mosaics can take a significant amount of time to analyze, especially when segment_individuals = TRUE is used in mosaic_analyze(). This is because the function needs to create in-memory arrays to segment individual using the watershed algorithm. This process utilizes a for-loop approach, iteratively analyzing each shape within the mosaic one at a time. To speed up processing, the function crops the original mosaic to the extent of the current shape before analyzing it. This reduces the resolution for that specific analysis, sacrificing some detail for faster processing.

Usage

mosaic_analyze_iter(
  mosaic,
  shapefile,
  basemap = NULL,
  r = 3,
  g = 2,
  b = 1,
  re = NA,
  nir = NA,
  swir = NA,
  tir = NA,
  plot = TRUE,
  verbose = TRUE,
  max_pixels = 3e+06,
  attribute = NULL,
  summarize_fun = "mean",
  segment_plot = FALSE,
  segment_individuals = FALSE,
  segment_index = "VARI",
  plot_index = "VARI",
  color_regions = rev(grDevices::terrain.colors(50)),
  alpha = 0.75,
  quantiles = c(0, 1),
  ...
)

Arguments

mosaic

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

shapefile

An optional shapefile containing regions of interest (ROIs) for analysis.

basemap

An optional basemap generated with mosaic_view().

r, g, b, re, nir, swir, tir

The red, green, blue, red-edge, near-infrared, shortwave Infrared, and thermal 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.

plot

Logical, indicating whether to generate plots (default: TRUE).

verbose

Logical, indicating whether to display verbose output (default: TRUE).

max_pixels

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

attribute

The attribute to be shown at the plot when plot is TRUE. Defaults to the first summary_fun and first segment_index.

summarize_fun

The function to compute summaries for the pixel values. Defaults to "mean," i.e., the mean value of the pixels (either at a plot- or individual-level) is returned.

segment_plot

Logical, indicating whether to segment plots (default: FALSE). If TRUE, the segment_index will be computed, and pixels with values below the threshold will be selected.

segment_individuals

Logical, indicating whether to segment individuals within plots (default: FALSE). If TRUE, the segment_index will be computed, and pixels with values below the threshold will be selected, and a watershed-based segmentation will be performed.

segment_index

The index used for segmentation. The same rule as plot_index. Defaults to NULL

plot_index

The index(es) to be computed for the drawn plots. Either a single vegetation index (e.g., "GLAI"), a vector of indexes (e.g., c("GLAI", "NGRDI", "HUE")), or a custom index based on the available bands (e.g., "(R-B)/(R+B)"). See pliman_indexes() and image_index() for more details.

color_regions

The color palette for regions (default: rev(grDevices::terrain.colors(50))).

alpha

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

quantiles

the upper and lower quantiles used for color stretching.

...

Further arguments passed on to mosaic_analyze()

Value

A list containing the following objects:

  • result_plot: The results at a plot level.

  • result_plot_summ: The summary of results at a plot level. When segment_individuals = TRUE, the number of individuals, canopy coverage, and mean values of some shape statistics such as perimeter, length, width, and diameter are computed.

  • result_individ: The results at an individual level.

  • map_plot: An object of class mapview showing the plot-level results.

  • map_individual: An object of class mapview showing the individual-level results.