mosaic_crop: Crop a mosaic

View source: R/utils_mosaic.R

mosaic_cropR Documentation

Crop a mosaic

Description

Crop a SpatRaster object based on user-defined selection using an interactive map or plot.

Usage

mosaic_crop(
  mosaic,
  r = 3,
  g = 2,
  b = 1,
  re = 4,
  nir = 5,
  show = c("rgb", "index"),
  index = "R",
  max_pixels = 5e+05,
  downsample = NULL,
  ...
)

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).

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.

...

Additional arguments passed to mosaic_view().

Details

This function uses the mosaic_view function to display an interactive map or plot of the mosaic raster, allowing users to draw a rectangle to select the cropping area. The selected area is then cropped from the input mosaic and returned as a new SpatRaster object.

Value

A cropped version of mosaic based on the user-defined selection.

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' (works only in an interactive section)
cropped <- mosaic_crop(mosaic)
mosaic_view(cropped)
}


pliman documentation built on Oct. 15, 2023, 1:06 a.m.

Related to mosaic_crop in pliman...