nearblack: Interface to GDAL's nearblack utility

View source: R/nearblack.R

nearblackR Documentation

Interface to GDAL's nearblack utility

Description

This function provides an interface mirroring that of the GDAL command-line app nearblack. For a description of the utility and the arguments that it takes, see the documentation at https://gdal.org/programs/nearblack.html.

Usage

nearblack(
  infile,
  o = infile,
  ...,
  of,
  white,
  color,
  near,
  nb,
  setalpha,
  setmask,
  q,
  co,
  config_options = character(0),
  dryrun = FALSE
)

Arguments

infile

Character. Path to a GDAL-supported readable datasource.

o

Optionally, a character string giving the path to a GDAL-supported output file. If not supplied, defaults to codeinfile=, indicating that the input file should be modified in place.

...

Here, a placeholder argument that forces users to supply exact names of all subsequent formal arguments.

of, white, color, near, nb, setalpha, setmask, q, co

See the GDAL project's nearblack documentation for details.

config_options

A named character vector with GDAL config options, of the form c(option1=value1, option2=value2). (See here for a complete list of supported config options.)

dryrun

Logical (default FALSE). If TRUE, instead of executing the requested call to GDAL, the function will print the command-line call that would produce the equivalent output.

Value

Silently returns path to o.

Author(s)

Joshua O'Brien

Examples


td <- tempdir()
a_rast <- file.path(td, "a.tif")
b_rast <- file.path(td, "b.tif")
file.copy(system.file("extdata/tahoe.tif", package = "gdalUtilities"),
          a_rast)
file.copy(system.file("extdata/tahoe.tif", package = "gdalUtilities"),
          b_rast)
nearblack(a_rast, b_rast, of = "GTiff", near = 150)

## Check that it worked
if(require(terra)) {
    op <- par(mfcol = c(1, 2))
    r1 <- plot(rast(a_rast))
    r2 <- plot(rast(b_rast))
    par(op) ## Reset preexisting parameters
}


gdalUtilities documentation built on Aug. 10, 2023, 5:08 p.m.