creates a GDAL vrt file starting from a Raster object or file name.

create_virtrast(in_rast, out_vrt_file = NULL, out_extent = NULL,
  verbose = TRUE)

Arguments

in_rast

a *Raster object or the path to a valid raster file

out_vrt_file

character path were the vrt file must be saved. If NULL, the file is saved in "R" temporary folder , Default: NULL

out_extent

numeric (4) coordinates of a bounding box (xmin, ymin, xmax, ymax). If provided, the created vrt file will correspond to a "cropped" version of in_rast. If NULL, no cropping will be done, Default: NULL

verbose

If FALSE, processing messages are suppressed, Default: TRUE

Value

character path to the created vrt file

Examples

library(sprawl.data) in_file <- system.file("extdata/MODIS_test", "EVIts_test.tif", package = "sprawl.data") in_rast <- read_rast(in_file, bands = 5) vrt <- create_virtrast(in_rast)
#> create_virtrast --> Creating virtual file from in_rast
vrt
#> [1] "/tmp/Rtmpzfhi9J/file7852301873f6.vrt"
# reading in the vrt gives a raster object rast_from_vrt <- read_rast(vrt) rast_from_vrt
#> class : RasterLayer #> dimensions : 447, 331, 147957 (nrow, ncol, ncell) #> resolution : 231.6564, 231.6564 (x, y) #> extent : 12897004, 12973683, 1685995, 1789545 (xmin, xmax, ymin, ymax) #> coord. ref. : +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs #> data source : /tmp/Rtmpzfhi9J/file7852301873f6.vrt #> names : file7852301873f6 #> values : -323, 8706 (min, max) #>