I'm working with sets of aerial images in QGIS which are geocoded including orientation i.e. rotated.

After loading images QGIS draws a black box around each image that extends from the far west to far east pixel and from the far north to far south pixel. Within this black box lays the actual image in it's correct orientation.

To get rid of this black box I currently enter 0 in Layer Properties / Transparency / Additional NODATA value but the change has to be made on every single image. Unfortunately the transparency setting is not part of the Style definition and therefore cannot be copied from one to all other raster layers / images.

Is there better way to add a global NODATA value to all raster data in current workspace?

Raster Calculator won't work as there are no NODATA areas in the actual image files.

  • 2
    One way to do it would be to edit the qgis file in a text editor. Oct 11, 2016 at 18:32

3 Answers 3


You might want to look at VRTs (Virtual Rasters).

You can build these in QGIS, using Raster > Miscellaneous > Build virtual raster (Catalog), or directly on the command line using gdalbuildvrt

VRTs are small XML files which stitch together lots of rasters into one, "big" virtual raster which can be loaded and processed as if it was a single raster.

If you set the sourcenodata to "0 0 0" (assuming 3 bands, r,g,b) it should set pixels to transparent by setting the nodata value to 0. You probably want settings to look something like this:-

vrt settings for nodata values

I don't have any batches of aerial imagery to hand to test this, but it should allow you to merge all your images and set a single NODATA value for all of them across multiple bands.

I tried this by creating a VRT from a single aerial raster (without a nodata value) and it had the desired effect of setting nodata to 0, and the empty areas to transparent, so it's worth a try.

Also tried this from the Processing/GDAL menu in QGIS 2.16.3, and this option was missing. So use the old-style menu option or the command line to try this out.

  • oh, that's a shame :( The image I tried wasn't rotated (well, not in the geotranform anyway). Wasn't aware of that limitation.
    – Steven Kay
    Oct 10, 2016 at 21:33
  • Thanks for pointing me to VRT. Unfortunately gdalbuildvrt doesn't seem to like rotated images: Warning 6: gdalbuildvrt does not support rotated geo transforms. Skipping D:/Herbst 2016/Stenden/out_8bit/28_0092.tif
    – Pete Bo
    Oct 10, 2016 at 21:34

One way to do it is in the qgs file as suggested by Alexandre Neto

for all raster files replace

    <noDataList bandNo="1" useSrcNoData="0"/>
    <noDataList bandNo="2" useSrcNoData="0"/>
    <noDataList bandNo="3" useSrcNoData="0"/>


    <noDataList bandNo="1" useSrcNoData="0">
      <noDataRange min="0" max="0"/>
    <noDataList bandNo="2" useSrcNoData="0">
      <noDataRange min="0" max="0"/>
    <noDataList bandNo="3" useSrcNoData="0">
      <noDataRange min="0" max="0"/>

At least it worked easily for me on a project containing ONLY raster images and using Replace allin the editor. Thanks Alexandre!


Old question but I find the easiest way to do this using a python script that works on all selected layers

for layer in layers:
    provider = layer.dataProvider()
    provider.setNoDataValue(1, -9999) # first value is band number   


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.