I wish to apply one raster (GeoTIFF) as a mask to another raster. How can I do this using GDAL tools? I'd be happy to achieve this as a virtual raster because these images are large.
Will it be necessary to customise a .vrt
using a text editor, i.e., is there no way in gdalbuildvrt
to insert a <MaskBand>
? Or is the simplest approach to use gdal_calc.py
to multiply the rasters together?
gdalbuildvrt interim.vrt image1.tif image2.tif
and thengdal_translate -of VRT -b 1 -mask 2 interim.vrt final.vrt
.