I have a huge problem that I can't solve even after trying everything I can think of.

I am trying to do some analysis of the Lake Chad basin in QGIS (2.16.3). I downloaded Landsat 8 data from Earth Explorer, however I need 4 different satelite images to cover the whole basin. I did atmospheric correction and created a bandstack, the problem that now appears is that I have a "black border" around the single images.

I tried to fix this (as read in another post in here) by going to layer properties -> transparency -> additional no data value = 0 but it didn't work (I also tried raster -> analysis -> near red), so instead I took the single image, and did raster -> miscellaneous -> merge -> and checked "no data value". This worked to remove the black borders, but now when I try to merge the four single images into one, the black borders appear again.

Does anyone know how to fix this?

I've been trying to do this now for days, but I really don't know how to help myself at this point. I will add some images to clarify what I'm talking about.

These are the four images that I would like to merge together without the black borders:

This is what they look like after I removed the black borders (or at least that's what I think I did):

Now that's what they look like after I merged them:

And this is what happens when I set the RGB transparency to 0:

  • When you used the merge tool in QGIS, did you specify the NoData value in the GUI?
    – Aaron
    Mar 26, 2018 at 15:56
  • Do you mean when I tried to merge all four? This time I didn't do it, but I have done it before and I ended up with something that looked liked the last image I posted (with the white spaces) Mar 26, 2018 at 16:01
  • @Aaron, I tried again with the checked NoData value, and the outcome is as I thought - the merged image has all the white spaces Mar 26, 2018 at 16:58
  • I just tested using QGIS 2.18.17 with your same imagery and had no problem running the mosaic. I made sure that NoData was set to 0. It may be worth trying on a different version.
    – Aaron
    Mar 26, 2018 at 17:00
  • Somehow, you're answer was deleted. Could you maybe post it again? Mar 26, 2018 at 17:03

2 Answers 2


If you are setting the NoData value in the layer properties / transparency, I believe that's just for visualization purposes. Also, it means that your raster data does not have the NoData value set. I can think of two solutions:

  1. Inside QGIS:
    Use r.null from the processing toolbox to properly set your NoData value. Then do the merge, respecting the NoData

  2. From the command line:
    Use gdal_merge.py from the command line so you can control your inputs better. You can use the -n flag to indicate what is the NoData value. Your command would look something line this:
    gdal_merge.py -o merged_all.tif -n 0 RT_LC....your list of inputs here...

  • Will r.null work on multiband imagery, or do you need to run the algorithm on the bands individually?
    – Aaron
    Mar 26, 2018 at 18:14
  • I don't know. Grass r.* commands work for single band raster. So maybe the r.null option is not the best one.
    – Daniel
    Mar 26, 2018 at 18:56
  • Perhaps gdal_translate -a_nodata 0 ...? gis.stackexchange.com/a/41721/8104
    – Aaron
    Mar 26, 2018 at 19:05

The way it worked now for me was: Create a new shapefile (polygon) - toggle editing - add feature (make a square on the satellite image, leaving the black borders out) - safe. Then go to raster - extraction - clipper, put original raster that I wanted to clip as input, new shapefile as output - run this. In the clipped image, set no additional data value to 0; then when running the misc - merge of the four images (again, setting no data value to 0 in the merge window) and then it worked!! Also, I tried to use r.null but somehow always got an error message. Anyways, now it worked for me.

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.