Interactively crop a raster
to a boundary box specified by mouse clicks.
crop_from_click(x, plot = TRUE, ...)
A raster
.
A logical input that defines whether or not to plot x
before and after cropping.
Additional arguments passed to pretty_map
to customise plots.
The function returns a raster
and, if plot = TRUE
, a plot of the area before/after cropping.
The function is implemented as follows:
The function plots the supplied raster (x
), if plot = TRUE
;
Boundary coordinates delineating the area to which x
should be cropped are defined by mouse clicks on the plot;
The plotted raster is cropped using the minimum and maximum x and y coordinates of mouse clicks, via crop
;
The cropped raster is plotted, if plot = TRUE
;
The cropped raster is returned.
if (interactive()) crop_from_click(dat_gebco)