vrt.RdCreate a Virtual Raster Dataset (VRT) from a collection of file-based raster datasets (tiles). See gdalbuildvrt for details.
# S4 method for class 'character'
vrt(x, filename="", options=NULL, overwrite=FALSE, set_names=FALSE, return_filename=FALSE)
# S4 method for class 'SpatRasterCollection'
vrt(x, filename="", options=NULL, overwrite=FALSE, return_filename=FALSE)SpatRasterCollection or character vector with filenames of raster "tiles". That is, files that have data for, typically non-overlapping, sub-regions of an raster. See makeTiles
character. output VRT filename
character. All arguments as separate vector elements. Options as for gdalbuildvrt
logical. Should filename be overwritten if it exists?
logical. Add the layer names of the first tile to the vrt? If options includes "-separate" the name of each source file is added, and each input goes into a separate band in the VRT dataset
logical. If TRUE the filename is returned, otherwise a SpatRaster is returned
SpatRaster
A VRT can reference very many datasets. These are not all opened at the same time. The default is to open not more than 100 files. To increase performance, this maximum limit can be increased by setting the GDAL_MAX_DATASET_POOL_SIZE configuration option to a bigger value with setGDALconfig. Note that a typical user process on Linux is limited to 1024 simultaneously opened files.
r <- rast(ncols=100, nrows=100)
values(r) <- 1:ncell(r)
x <- rast(ncols=2, nrows=2)
filename <- paste0(tempfile(), "_.tif")
ff <- makeTiles(r, x, filename)
ff
#> [1] "/tmp/RtmpvEtVHb/filef5d354c8c64d6_1.tif"
#> [2] "/tmp/RtmpvEtVHb/filef5d354c8c64d6_2.tif"
#> [3] "/tmp/RtmpvEtVHb/filef5d354c8c64d6_3.tif"
#> [4] "/tmp/RtmpvEtVHb/filef5d354c8c64d6_4.tif"
#vrtfile <- paste0(tempfile(), ".vrt")
#v <- vrt(ff, vrtfile)
## output in lower resolution
#vrtfile <- paste0(tempfile(), ".vrt")
#v <- vrt(ff, vrtfile, options = c("-tr", 5, 5))
#head(readLines(vrtfile))
#v