gdalbuildvrt
Builds a VRT from a list of datasets.
- Provided by: gdal-bin (Version: 3.12.2+dfsg-1build2)
- Source: gdal
- Report a bug
Builds a VRT from a list of datasets.
gdalbuildvrt [--help] [--long-usage] [--help-general]
[--quiet]
[[-strict]|[-non_strict]]
[-tile_index <field_name>]
[-resolution user|average|common|highest|lowest|same]
[-tr <xres> <yes>] [-input_file_list <filename>]
[[-separate]|[-pixel-function <function>]]
[-pixel-function-arg <NAME>=<VALUE>]...
[-allow_projection_difference] [-sd <n>] [-tap]
[-te <xmin> <ymin> <xmax> <ymax>] [-addalpha] [-b <band>]...
[-hidenodata] [-overwrite]
[-srcnodata "<value>[ <value>]..."]
[-vrtnodata "<value>[ <value>]..."] [-a_srs <srs_def>]
[-r nearest|bilinear|cubic|cubicspline|lanczos|average|mode]
[-oo <NAME>=<VALUE>]... [-co <NAME>=<VALUE>]...
[-ignore_srcmaskband]
[-nodata_max_mask_threshold <threshold>]
<vrt_dataset_name> [<src_dataset_name>]...
This program builds a VRT (Virtual Dataset) that is a mosaic of a list of input GDAL datasets. The list of input GDAL datasets can be specified at the end of the command line, put in a text file (one filename per line) for very long lists, or it can be a MapServer tileindex (see the gdaltindex utility). If using a tile index, all entries in the tile index will be added to the VRT.
NOTE:
TIP:
See gdal raster mosaic and gdal raster stack.
With -separate, each input goes into a separate band in the VRT dataset. Otherwise, the files are considered as source rasters of a larger mosaic and the VRT file has the same number of bands as the input files.
If one GDAL dataset is made of several subdatasets and has 0 raster bands, all the subdatasets will be added to the VRT rather than the dataset itself.
gdalbuildvrt does some checks to ensure that all files that will be put in the resulting VRT have similar characteristics: number of bands, projection, color interpretation, etc. If not, files that do not match the common characteristics will be skipped unless -strict is used. (This is only true in the default mode, and not when using the -separate option)
Starting with GDAL 3.12, a function (e.g., min, mean, median) can be specified (-pixel-function) to calculate pixel values from overlapping inputs. If no function is specified, or in earlier versions, the order of the input list is used to determine priority. Files that are listed at the end are the ones from which the content will be fetched. Note that nodata will be taken into account to potentially fetch data from lower-priority datasets, but currently, alpha channel is not taken into account to do alpha compositing (so a source with alpha=0 appearing on top of another source will override its content). This might be changed in later versions.
highest will pick the smallest values of pixel dimensions within the set of source rasters.
lowest will pick the largest values of pixel dimensions within the set of source rasters.
average is the default and will compute an average of pixel dimensions within the set of source rasters.
user must be used in combination with the -tr option to specify the target resolution.
same (added in GDAL 3.11) checks that all source rasters have the same resolution and errors out when this is not the case.
common (added in GDAL 3.11) determines the greatest common divisor of the source pixel dimensions, e.g. 0.2 for source pixel dimensions of 0.4 and 0.6.
Starting with GDAL 3.3, if a source has a mask band (internal/external mask band, or alpha band), a <ComplexSource> element is created by default with a <UseMaskBand>true</UseMaskBand> child element, to instruct the VRT driver to use the mask band of the source to mask pixels being composited. This is a generalization of the NODATA element. When specifying the -ignore_srcmaskband option, the mask band of sources will not be taken into account, and in case of overlapping between sources, the last one will override previous ones in areas of overlap.
Insert a <NoDataFromMaskSource> source, which replaces the value of the source with the value of -vrtnodata (or 0 if not specified) when the value of the mask band of the source is less or equal to the threshold. This is typically used to transform a R,G,B,A image into a R,G,B one with a NoData value.
Starting with GDAL 3.8, all bands of each input file are added as separate VRT bands, unless -b is specified to select a subset of them. Before GDAL 3.8, only the first band of each input file was placed into a new VRT band, and -b was ignored.
Added in version 3.12.
Added in version 3.12.
Added in version 3.10.
Added in version 3.4.2.
Added in version 3.4.2.
Enables writing the absolute path of the input datasets. By default, input filenames are written in a relative way with respect to the VRT filename (when possible).
gdalbuildvrt doq_index.vrt doq/*.tif
gdalbuildvrt -input_file_list my_list.txt doq_index.vrt
gdalbuildvrt -separate rgb.vrt red.tif green.tif blue.tif
gdalbuildvrt -hidenodata -vrtnodata "0 0 255" doq_index.vrt doq/*.tif
This utility is also callable from C with GDALBuildVRT().
Even Rouault <even.rouault@spatialys.com>
1998-2026