Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/mosaic_rasters.R
Mosaic raster files using GDAL Utilities
1 2 3 4 5 6 7 8 9 10 11 12 13 |
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? |
separate |
Logical. (starting with GDAL 1.7.0) Place each input file into a separate stacked band. Unlike gdalbuildvrt, the full stack is placed in the mosaic, not just the first band. |
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. |
gdalwarp_index |
Numeric. If gdalwarp_index is numeric, the value is used as the index of the gdalfile to match projections and resolutions against when file projections don't match. The default = 1 (the first input file). |
gdalwarp_params |
List. Set gdalwarp parameters if input file projections don't match. t_srs and tr set here will override those chosen by gdalwarp_index. In general, the only thing you would set here is the resampling algorithm, which defaults to nearest neighbor ("near"). |
force_ot |
Character. ("Byte"/"Int16"/"UInt16"/"UInt32"/"Int32"/"Float32"/"Float64"/"CInt16"/"CInt32"/"CFloat32"/"CFloat64") Forces all bands to be the same datatype. This is helpful if you are using input files of different data types and output formats (e.g. GTiff) that don't support mixed datatypes. |
verbose |
Logical. Enable verbose execution? Default is FALSE. |
... |
Parameters to pass to |
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.
Either a list of NULLs or a list of RasterBricks depending on whether output_Raster is set to TRUE.
Jonathan A. Greenberg (gdalUtils@estarcion.net)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # 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.
outdir <- tempdir()
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=file.path(outdir,"test_mosaic.envi"),
separate=TRUE,of="ENVI",verbose=TRUE)
gdalinfo("test_mosaic.envi")
}
|
Warning messages:
1: In gdal_setInstallation() :
No GDAL installation found. Please install 'gdal' before continuing:
- www.gdal.org (no HDF4 support!)
- 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.5-18, (SVN revision 1082)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 3.0.4, released 2020/01/28
Path to GDAL shared files: /usr/share/gdal
GDAL binary built with GEOS: TRUE
Loaded PROJ runtime: Rel. 6.3.1, February 10th, 2020, [PJ_VERSION: 631]
Path to PROJ shared files: /usr/share/proj
Linking to sp version:1.4-4
To mute warnings of possible GDAL/OSR exportToProj4() degradation,
use options("rgdal_show_exportToProj4_warnings"="none") before loading rgdal.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.