gdalUtils (version 2.0.1.5)

gdalmanage: gdalmanage

Description

R wrapper for gdalmanage: Identify, delete, rename and copy raster data files

Usage

gdalmanage(mode, datasetname, newdatasetname, r, u, f,
  ignore.full_scan = TRUE, verbose = FALSE)

Arguments

mode
Character. Mode of operation. "identify" | "copy" | "rename" | "delete". See details.
datasetname
Character. Raster file to operate on.
newdatasetname
Character. For copy and rename modes, you provide a source filename and a target filename, just like copy and move commands in an operating system.
r
Logical. Recursively scan files/folders for raster files.
u
Logical. Report failures if file type is unidentified.
f
Character. format. Specify format of raster file if unknown by the application. Uses short data format name (e.g. GTiff).
ignore.full_scan
Logical. If FALSE, perform a brute-force scan if other installs are not found. Default is TRUE.
verbose
Logical. Enable verbose execution? Default is FALSE.

Value

  • Character.

Details

This is an R wrapper for the 'gdalmanage' function that is part of the Geospatial Data Abstraction Library (GDAL). It follows the parameter naming conventions of the original function, with some modifications to allow for more R-like parameters. For all parameters, the user can use a single character string following, precisely, the gdalinfo format (http://gdal.org/gdalmanage.html), or, in some cases, can use R vectors to achieve the same end.

Mode of operation

  • mode="identify",datasetname: List data format of file.
mode="copy",datasetname,newdatasetname: Create a copy of the raster file with a new name. mode="rename",datasetname,newdatasetname: Change the name of the raster file. mode="delete",datasetname: Delete raster file.

References

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

Examples

Run this code
gdal_setInstallation()
valid_install <- !is.null(getOption("gdalUtils_gdalPath"))
if(valid_install)
{
	# Using identify mode
	# Report the data format of the raster file by using the identify mode
 # and specifying a data file name:
	src_dataset <- system.file("external/tahoe_highrez.tif", package="gdalUtils")
	gdalmanage(mode="identify",datasetname=src_dataset)

	# Recursive mode will scan subfolders and report the data format:
	src_dir <- system.file("external/", package="gdalUtils")
	gdalmanage(mode="identify",datasetname=src_dir,r=TRUE)

# Using copy mode
		# Copy the raster data:
		file_copy <- tempfile(fileext=".tif")
		gdalmanage(mode="copy",src_dataset,file_copy)
		file.exists(file_copy)

		# Using rename mode
		# Rename the raster data:
		new_name <- tempfile(fileext=".tif")
		gdalmanage(mode="rename",file_copy,new_name)
		file.exists(new_name)

		# Using delete mode
		# Delete the raster data:
		gdalmanage(mode="delete",new_name)
		file.exists(new_name)
}

Run the code above in your browser using DataCamp Workspace