View source: R/gdalmdimtranslate.R
| gdalmdimtranslate | R Documentation | 
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.
gdalmdimtranslate(
  src_filename,
  dst_filename,
  ...,
  co,
  IF,
  of,
  array,
  group,
  subset,
  scaleaxes,
  oo,
  config_options = character(0),
  dryrun = FALSE
)
| 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  | 
| dryrun | Logical (default  | 
Silently returns path to dst_filename.
Joshua O'Brien
## 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)")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.