gdal_cmd_builder: gdal_cmd_builder

Description Usage Arguments Details Value Author(s) References Examples

View source: R/gdal_cmd_builder.R

Description

Helper function for building GDAL commands.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
gdal_cmd_builder(
  executable,
  parameter_variables = c(),
  parameter_values = c(),
  parameter_order = c(),
  parameter_noflags = c(),
  parameter_doubledash = c(),
  parameter_noquotes = c(),
  gdal_installation_id = 1,
  python_util = FALSE,
  verbose = FALSE
)

Arguments

executable

Character. The GDAL command to use (e.g. "gdal_translate")

parameter_variables

List. A list of parameter names, organized by type.

parameter_values

List. A list of the parameters names/values.

parameter_order

Character. The order of the parameters for the GDAL command.

parameter_noflags

Character. Parameters which do not have a flag.

parameter_doubledash

Character. Parameters which should have a double dash "–".

parameter_noquotes

Character. Parameters which should not be wrapped in quotes (vector parameters only, at present).

gdal_installation_id

Numeric. The ID of the GDAL installation to use. Defaults to 1.

python_util

Logical. Is the utility a python utility? Default = FALSE.

verbose

Logical. Enable verbose execution? Default is FALSE.

Details

This function takes the executable name (e.g. "gdal_translate"), a list of parameter names organized by logical, vector, scalar, character, repeatable, a list of values of these parameters, the order they should be used in the GDAL command, and a list of parameters that should not have a flag, and returns a properly formatted GDAL command (with the full path-to-executable) that should work with a system() call.

Sometimes, a user may not want to use the most recent GDAL install (gdal_installation_id=1), so the gdal_installation_id can be used to set a different install. This is often used with gdal_chooseInstallation if, for instance, the particular GDAL installation required needs a specific driver that may not be available in all installations.

In general, an end user shouldn't need to use this function – it is used by many of the GDAL wrappers within gdalUtils.

Value

Formatted GDAL command for use with system() calls.

Author(s)

Jonathan A. Greenberg (gdalUtils@estarcion.net)

References

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
## Not run:  
# This builds a gdal_translate command.
executable <- "gdal_translate"

parameter_variables <- list(
			logical = list(
					varnames <- c("strict","unscale","epo",
					"eco","q","sds","stats")),
			vector = list(
					varnames <- c("outsize","scale","srcwin",
					"projwin","a_ullr","gcp")),
			scalar = list(
					varnames <- c("a_nodata")),
			character = list(
					varnames <- c("ot","of","mask","expand","a_srs",
					"src_dataset","dst_dataset")),
			repeatable = list(
					varnames <- c("b","mo","co")))

parameter_order <- c(
			"strict","unscale","epo","eco","q","sds","stats",
			"outsize","scale","srcwin","projwin","a_ullr","gcp",
			"a_nodata",
			"ot","of","mask","expand","a_srs",
			"b","mo","co",
			"src_dataset","dst_dataset")

parameter_noflags <- c("src_dataset","dst_dataset")

# Now assign some parameters:
parameter_values = list(
	src_dataset = "input.tif",
	dst_dataset = "output.envi",
	of = "ENVI",
	strict = TRUE
)

cmd <- gdal_cmd_builder(
			executable=executable,
			parameter_variables=parameter_variables,
			parameter_values=parameter_values,
			parameter_order=parameter_order,
			parameter_noflags=parameter_noflags)

cmd
system(cmd,intern=TRUE) 

## End(Not run)

gearslaboratory/gdalUtils documentation built on Feb. 17, 2020, 8:09 a.m.