autoCreateWarpedVRT: Create a virtual warped dataset automatically

View source: R/gdal_util.R

autoCreateWarpedVRTR Documentation

Create a virtual warped dataset automatically

Description

autoCreateWarpedVRT() creates a warped virtual dataset representing the input raster warped into a target coordinate system. The output virtual dataset will be "north-up" in the target coordinate system. GDAL automatically determines the bounds and resolution of the output virtual raster which should be large enough to include all the input raster. Wrapper of GDALAutoCreateWarpedVRT() in the GDAL Warper API.

Usage

autoCreateWarpedVRT(
  src_ds,
  dst_wkt,
  resample_alg,
  src_wkt = "",
  max_err = 0,
  alpha_band = FALSE
)

Arguments

src_ds

An object of class GDALRaster for the source dataset.

dst_wkt

WKT string specifying the coordinate system to convert to. If empty string ("") no change of coordinate system will take place.

resample_alg

Character string specifying the sampling method to use. One of NearestNeighbour, Bilinear, Cubic, CubicSpline, Lanczos, Average, RMS or Mode.

src_wkt

WKT string specifying the coordinate system of the source raster. If empty string it will be read from the source raster (the default).

max_err

Numeric scalar specifying the maximum error measured in input pixels that is allowed in approximating the transformation (0.0 for exact calculations, the default).

alpha_band

Logical scalar, TRUE to create an alpha band if the source dataset has none. Defaults to FALSE.

Value

An object of class GDALRaster for the new virtual dataset. An error is raised if the operation fails.

Note

The returned dataset will have no associated filename for itself. If you want to write the virtual dataset to a VRT file, use the ⁠$setFilename()⁠ method on the returned GDALRaster object to assign a filename before it is closed.

Examples

elev_file <- system.file("extdata/storml_elev.tif", package="gdalraster")
ds <- new(GDALRaster, elev_file)

ds2 <- autoCreateWarpedVRT(ds, epsg_to_wkt(5070), "Bilinear")
ds2$info()

## set filename before close if a VRT file is needed for the virtual dataset
# ds2$setFilename("/path/to/file.vrt")

ds2$close()
ds$close()

gdalraster documentation built on June 8, 2025, 12:37 p.m.