Learn R Programming

terra (version 1.7-55)

vrt: Virtual Raster Dataset

Description

Create a Virtual Raster Dataset (VRT) from a collection of file-based raster datasets (tiles). See gdalbuildvrt for details.

Usage

# S4 method for character
vrt(x, filename="", options=NULL, overwrite=FALSE, set_names=FALSE, return_filename=FALSE)

Value

SpatRaster

Arguments

x

character. Filenames of raster "tiles". See tiles

filename

character. output VRT filename

options

character. All arguments as separate vector elements. Options as for gdalbuildvrt

overwrite

logical. Should filename be overwritten if it exists?

set_names

logical. Add the layer names of the first tile to the vrt?

return_filename

logical. If TRUE the filename is returned, otherwise a SpatRaster is returned

See Also

makeTiles to create tiles; makeVRT to create a .vrt file for a binary raster file that does not have a header file. vrt_tiles to get the filenames of the tiles in a VRT.

Examples

Run this code
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

#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

Run the code above in your browser using DataLab