mosaic_rasters: Mosaic raster files using GDAL Utilities

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

View source: R/mosaic_rasters.R

Description

Mosaic raster files using GDAL Utilities

Usage

1
2
mosaic_rasters(gdalfile, dst_dataset, output.vrt = NULL,
  output_Raster = FALSE, trim_margins = NULL, verbose = FALSE, ...)

Arguments

gdalfile

Character. Input files (as a character vector) or a wildcard search term (e.g. "*.tif")

dst_dataset

Character. The destination file name.

output.vrt

Character. Output VRT file. If NULL a temporary .vrt file will be created.

output_Raster

Logical. Return output dst_dataset as a RasterBrick?

trim_margins

Numeric. Pre-crop the input tiles by a fixed number of pixels before mosaicking. Can be a single value or four values representing the left, top, right, and bottom margins, respectively.

verbose

Logical. Enable verbose execution? Default is FALSE.

...

Parameters to pass to gdalbuildvrt or gdal_translate.

Details

This function mosaics a set of input rasters (gdalfile) using parameters found in gdalbuildvrt and subsequently exports the mosaic to an output file (dst_dataset) using parameters found in gdal_translate. The user can choose to preserve the intermediate output.vrt file, but in general this is not needed.

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 ([email protected])

See Also

gdalbuildvrt, gdal_translate

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# We'll pre-check to make sure there is a valid GDAL install
# and that raster and rgdal are also installed.
# Note this isn't strictly neccessary, as executing the function will
# force a search for a valid GDAL install.
gdal_setInstallation()
valid_install <- !is.null(getOption("gdalUtils_gdalPath"))
if(require(raster) && require(rgdal) && valid_install)
{
layer1 <- system.file("external/tahoe_lidar_bareearth.tif", package="gdalUtils")
layer2 <- system.file("external/tahoe_lidar_highesthit.tif", package="gdalUtils")
mosaic_rasters(gdalfile=c(layer1,layer2),dst_dataset="test_mosaic.envi",separate=TRUE,of="ENVI",
		verbose=TRUE)
gdalinfo("test_mosaic.envi")
}

Example output

sh: 1: cannot create /dev/null: Permission denied
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)
Loading required package: raster
Loading required package: sp
Loading required package: rgdal
rgdal: version: 1.2-10, (SVN revision 673)
 Geospatial Data Abstraction Library extensions to R successfully loaded
 Loaded GDAL runtime: GDAL 1.10.1, released 2013/08/26
 Path to GDAL shared files: /usr/share/gdal/1.10
 Loaded PROJ.4 runtime: Rel. 4.8.0, 6 March 2012, [PJ_VERSION: 480]
 Path to PROJ.4 shared files: (autodetected)
WARNING: no proj_defs.dat in PROJ.4 shared files
 Linking to sp version: 1.2-3 

gdalUtils documentation built on May 29, 2017, 12:11 p.m.