mosaic_crop | R Documentation |
Crop a SpatRaster
object based on user-defined selection using an
interactive map or plot.
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,
...
)
mosaic |
A mosaic of class |
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 |
... |
Additional arguments passed to |
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.
A cropped version of mosaic
based on the user-defined selection.
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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.