batch_gdal_translate: batch_gdal_translate

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/batch_gdal_translate.R

Description

Runs gdal_translate on a batch of files

Usage

1
2
3
4
5
6
7
8
9
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

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).

Value

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

Author(s)

Jonathan A. Greenberg (gdalUtils@estarcion.net)

References

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

See Also

gdal_translate, list.files

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run:  
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

## End(Not run)

Example output

[1] "tahoe_highrez.tif"          "tahoe_lidar_bareearth.tif" 
[3] "tahoe_lidar_highesthit.tif"
sh: 1: cannot create /dev/null: Permission denied
NULL
Warning messages:
1: In gdal_setInstallation() :
  No GDAL installation found. Please install 'gdal' before continuing:
	- www.gdal.org (no HDF4 support!)
	- www.trac.osgeo.org/osgeo4w/ (with HDF4 support RECOMMENDED)
	- www.fwtools.maptools.org (with HDF4 support)

2: In gdal_setInstallation() : If you think GDAL is installed, please run:
gdal_setInstallation(ignore.full_scan=FALSE)
character(0)

gdalUtils documentation built on Feb. 14, 2020, 1:08 a.m.