gdalbuildvrt
Create virtual raster from raster list
TLDR
Make a virtual mosaic from all TIFF files contained in a directory
Make a virtual mosaic from files whose name is specified in a text file
Make an RGB virtual mosaic from 3 single-band input files
Make a virtual mosaic with blue background color (RGB: 0 0 255)
SYNOPSIS
gdalbuildvrt [options] <output_vrt_file> [<src_dataset> ...]|-input_file_list <filename>
PARAMETERS
<output_vrt_file>
The name of the output VRT file to be created. This is a mandatory argument.
<src_dataset> ...
One or more input GDAL-supported raster datasets. These are the source files from which the VRT will be built.
-input_file_list <filename>
Reads a list of input datasets from a text file, one path per line. This is an alternative to listing all input datasets on the command line.
-r <resampling_method>
Specifies the resampling algorithm to use when a pixel needs to be resampled (e.g., when inputs have different resolutions or extents). Options include nearest, bilinear, cubic, cubicspline, lanczos, average, mode. Default is nearest.
-te <xmin> <ymin> <xmax> <ymax>
Defines the target extent of the output VRT in georeferenced coordinates. The coordinates should be in the target SRS of the VRT.
-tr <xres> <yres>
Sets the target resolution of the output VRT in georeferenced units (e.g., meters or degrees per pixel). Requires -te to be specified.
-ts <xsize> <ysize>
Sets the target size of the output VRT in pixels and lines. This is an alternative to -tr for defining output dimensions.
-a_srs <srs_def>
Assigns a target Spatial Reference System (SRS) to the VRT. Can be an EPSG code (e.g., 'EPSG:4326'), WKT, PROJ.4 string, or a file path to an SRS definition.
-a_ullr <ulx> <uly> <lrx> <lry>
Assigns georeferenced coordinates to the VRT from its upper-left and lower-right corners. This implies the VRT's extent and resolution.
-vrtnodata <value>
Assigns a nodata value to the VRT bands. Pixels matching this value are considered transparent. Can be a single value or a comma-separated list for multiple bands.
-srcnodata <value>
Overrides the nodata value of the source datasets before they are used in the VRT. Can be a single value or 'none' to ignore source nodata.
-b <band_number>
Selects a specific band from the source datasets to be included in the VRT. This option can be specified multiple times for multiple bands.
-sd <subdataset_number>
Selects a specific subdataset from hierarchical source datasets (e.g., HDF5, NetCDF) to be processed.
-separate
Places each input file into a separate band in the VRT. Requires all input files to have the same dimensions. Useful for combining different spectral bands from different files.
-allow_projection_difference
Allows input datasets with different projections. When enabled, all input datasets will be reprojected on-the-fly to the VRT's SRS (determined by the first input or -a_srs).
-overwrite
Overwrites an existing VRT file if it already exists.
-q
Suppresses progress messages and other non-error output during execution.
-stats
Forces computation of statistics (min/max, mean, stddev) on the VRT during its creation. This can be time-consuming for large datasets.
DESCRIPTION
gdalbuildvrt is a powerful command-line utility provided by the GDAL (Geospatial Data Abstraction Library) project. Its primary purpose is to create a Virtual Raster Dataset (VRT) file from one or more GDAL-supported raster datasets. A VRT file is essentially an XML text file that describes how to access and display data from other raster files without actually duplicating the pixel data. This allows users to mosaic, reproject, or transform multiple datasets into a single logical view without consuming significant disk space. gdalbuildvrt is particularly useful for creating large seamless mosaics from numerous smaller image tiles, or for defining complex data views that combine different bands or datasets, all while preserving the original data integrity and minimizing processing time until the data is actually accessed. It supports various options to control the output VRT's spatial extent, resolution, coordinate system, and resampling methods.
CAVEATS
VRT files are XML definitions, not actual raster data. While they provide a unified view, performance can depend on the underlying data and the complexity of the VRT. Large VRTs combining many small files might have performance overhead due to numerous file accesses. Using -allow_projection_difference can lead to on-the-fly reprojection, which is computationally intensive when the VRT is accessed. Changes to source datasets are reflected in the VRT, but the VRT itself doesn't automatically update if source files are deleted or moved without recreating the VRT. It's crucial to ensure source datasets remain accessible at their original paths.
VRT XML STRUCTURE
A VRT file is a human-readable XML document. It contains references to source datasets, their georeferencing information, band properties, and how they contribute to the virtual dataset. This transparency allows advanced users to manually edit VRTs for fine-grained control or specific edge cases not directly covered by command-line options.
ON-THE-FLY PROCESSING
VRTs enable on-the-fly processing, often referred to as 'lazy evaluation'. Operations like mosaicking, reprojection, or band selection are not performed until the VRT is opened by a GDAL-aware application (e.g., QGIS, ArcMap, or another GDAL utility) and pixels are actually requested. This approach saves disk space and processing time by only processing the necessary data when it's accessed, rather than pre-computing entire new files.
COMMON USE CASES
- Mosaicking: Combining numerous adjacent satellite images or aerial photos into a single seamless image view without duplicating data.
- Clipping/Subsetting: Defining a smaller area of interest from a larger dataset virtually, without creating a new clipped file.
- Reprojection: Creating a virtual dataset in a different coordinate system without re-saving the entire dataset.
- Band Manipulation: Creating virtual datasets with specific band combinations or operations (e.g., using specific bands from different files as a single virtual multi-band image).
HISTORY
gdalbuildvrt is an integral part of the GDAL library, which was first released in 1998 by Frank Warmerdam. The Virtual Raster Dataset (VRT) format and gdalbuildvrt utility were introduced early in GDAL's development, providing a flexible and efficient way to manage and combine geospatial raster data without data duplication. Its development has mirrored GDAL's evolution, with continuous improvements in capabilities, performance, and support for new data formats and projection systems. It has become a fundamental tool in geospatial data processing workflows, especially for handling large volumes of imagery and creating seamless mosaics.
SEE ALSO
gdalinfo(1), gdal_translate(1), gdalwarp(1)