This function aligns and crops the image using either base or mapview
visualization. This is useful to prepare the images to be analyzed with
analyze_objects_shp()
Usage
image_prepare(
img,
viewer = get_pliman_viewer(),
downsample = NULL,
max_pixels = 1e+06
)
Arguments
- img
An optional
Image
object- viewer
The viewer option. If not provided, the value is retrieved using
get_pliman_viewer()
. This option controls the type of viewer to use for interactive plotting. The available options are "base" and "mapview". If set to "base", the base R graphics system is used for interactive plotting. If set to "mapview", the mapview package is used. To set this argument globally for all functions in the package, you can use theset_pliman_viewer()
function. For example, you can runset_pliman_viewer("mapview")
to set the viewer option to "mapview" for all functions.- downsample
integer; for each dimension the number of pixels/lines/bands etc that will be skipped; Defaults to
NULL
, which will find the best downsampling factor to approximate themax_pixels
value.- max_pixels
integer > 0. Maximum number of cells to use for the plot. If
max_pixels < npixels(img)
, regular sampling is used before plotting.
Examples
# Example usage:
if (interactive() && requireNamespace("EBImage")) {
img <- image_pliman("mult_leaves.jpg")
image_prepare(img, viewer = "mapview")
}
#> Warning: GDAL Message 1: +init=epsg:XXXX syntax is deprecated. It might return a CRS with a non-EPSG compliant axis order.
#> Loading required namespace: leaflet.extras
#> Loading required package: shiny
#>
#> Listening on http://127.0.0.1:6534
#> Error in UseMethod("st_transform"): no applicable method for 'st_transform' applied to an object of class "NULL"