gdalUtils (version 2.0.1.5)

batch_gdal_translate: batch_gdal_translate

Description

Runs gdal_translate on a batch of files

Usage

batch_gdal_translate(infiles, outdir, outsuffix = "_conv.tif",
  pattern = NULL, recursive = FALSE, verbose = FALSE, ...)

Arguments

infiles
Character. A directory or a character vector of files (including their path). If a directory, all files matching the pattern will be converted.
outdir
Character. Output directory to save the output files.
outsuffix
Character. The suffix to append to the input filename (minus its extension) to generate the output filename(s).
pattern
Character. If infiles is a directory, this is used to limit the file it is searching for.
recursive
Logical. If infiles is a directory, should files be searched for recursively?
verbose
Logical. Enable verbose execution? Default is FALSE.
...
Parameters to pass to gdal_translate

Value

  • Either a list of NULLs or a list of RasterBricks depending on whether output_Raster is set to TRUE.

Details

This function is designed to run gdal_translate in batch mode. Files are passed to the function either directly as a character vector of filenames, or by passing it a directory and (typically) a search pattern (e.g. pattern=".tif"). gdal_translate will execute based on parameters passed to it, and the output file will be named based on the input file (stripped of its extension), with the outsuffix appended to it.

If a parallel engine is started and registered with foreach, this program will run in parallel (one gdal_translate per worker).

References

http://www.gdal.org/gdal_translate.html

See Also

gdal_translate, list.files

Examples

Run this code
input_folder <- system.file("external",package="gdalUtils")
list.files(input_folder,pattern=".tif")
output_folder <- tempdir()
# library(spatial.tools)
# sfQuickInit() # from package spatial.tools to launch a parallel PSOCK cluster
batch_gdal_translate(infiles=input_folder,outdir=output_folder,
	outsuffix="_converted.envi",of="ENVI",pattern=".tif$")
list.files(output_folder,pattern="_converted.envi$")
# sfQuickStop() # from package spatial.tools to stop a parallel PSOCK cluster

Run the code above in your browser using DataLab