gdalmdimtranslate: Interface to GDAL's gdalmdimtranslate utility

View source: R/gdalmdimtranslate.R

gdalmdimtranslateR Documentation

Interface to GDAL's gdalmdimtranslate utility

Description

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

Usage

gdalmdimtranslate(
  src_filename,
  dst_filename,
  ...,
  co,
  IF,
  of,
  array,
  group,
  subset,
  scaleaxes,
  oo,
  config_options = character(0),
  dryrun = FALSE
)

Arguments

src_filename

Character. Path to a GDAL-supported readable datasource.

dst_filename

Character. Path to a GDAL-supported output file.

...

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

co, IF, of, array, group, subset, scaleaxes, oo

See the GDAL project's gdalmdimtranslate 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 dst_filename.

Author(s)

Joshua O'Brien

Examples


## A simple dataset bundled with the sf package
FF <- system.file("nc/cropped.nc", package = "sf")
td <- tempdir()
out_tiff <- file.path(td, "out.tiff")
gdalinfo(FF)
gdalmdimtranslate(FF, out_tiff, array = "sst")
gdalinfo(out_tiff)

## A more interesting dataset bundled with the stars package
if(require(terra)) {
    FF <- system.file("nc/reduced.nc", package = "stars")
    gdalinfo(FF)
    td <- tempdir()
    out_1_tiff <- file.path(td, "out_1.tiff")
    gdalmdimtranslate(FF, out_1_tiff, array = "sst")
    plot(rast(out_1_tiff),
         main = "Sea Surface Temperature\n(2x2 degree cells)")
    ## Translate to a tiff, coarsen by a factor of 5
    out_2_tiff <- file.path(td, "out_2.tiff")
    gdalmdimtranslate(FF, out_2_tiff, array = "sst",
                      scaleaxes = "lon(5),lat(5)")
    plot(rast(out_2_tiff),
         main = "Sea Surface Temperature\n(10x10 degree cells)")
}


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