Interactively crop a raster to a boundary box specified by mouse clicks.

crop_from_click(x, plot = TRUE, ...)

Arguments

x

A raster.

plot

A logical input that defines whether or not to plot x before and after cropping.

...

Additional arguments passed to pretty_map to customise plots.

Value

The function returns a raster and, if plot = TRUE, a plot of the area before/after cropping.

Details

The function is implemented as follows:

  1. The function plots the supplied raster (x), if plot = TRUE;

  2. Boundary coordinates delineating the area to which x should be cropped are defined by mouse clicks on the plot;

  3. The plotted raster is cropped using the minimum and maximum x and y coordinates of mouse clicks, via crop;

  4. The cropped raster is plotted, if plot = TRUE;

  5. The cropped raster is returned.

Author

Edward Lavender

Examples

if (interactive()) crop_from_click(dat_gebco)