1

I have loaded an ECW file into QGIS (v3.28.2 and also tried 3.30) and a transparency band is recognised as "Band 4: AllOpacity (Alpha)", however the raster is still displaying a black background of the raster extent. The alpha band value of this black background is 255. Is there a way I can make this black background transparent? Using GDAL version 3.6.1, ECW Driver: SDK 5.5.

enter image description here

6
  • Could you share some small test image?
    – user30184
    Commented Apr 26, 2023 at 5:58
  • @user30184 I've updated the question with an image
    – Saj
    Commented Apr 26, 2023 at 6:21
  • Thanks. I actually meant a real ECW image that could be downloaded but I suppose I have found such image already.
    – user30184
    Commented Apr 26, 2023 at 6:53
  • Could you make a test with this image raw.githubusercontent.com/OSGeo/gdal/master/autotest/gdrivers/…? It works as it should for me.
    – user30184
    Commented Apr 26, 2023 at 7:06
  • Other ECW files work for me as well. It must be an issue with how the ECW was created. I have solved the issue using the answer below. Thank you
    – Saj
    Commented Apr 27, 2023 at 2:00

1 Answer 1

1

One problem with ECW images is the 'black' pixels will have some variance in their values, which means you cannot simply set 255,255,255 to be transparent. To make the background transparent you can use the QGIS function "Near Black", which will turn values that are approximately 'black' into true 'black', and then you can set that to be transparent.

This will also convert the ECW to a TIF format image, which may increase the size, so use compression if/when you save it.

1
  • 1
    Thank you, using the 'Near Black' tool solved the issue for me. However I had to add the '-setalpha' command to replace the bad alpha band with one I could use for setting transparency. I used the answer in this thread: gis.stackexchange.com/questions/234590/…
    – Saj
    Commented Apr 27, 2023 at 2:04

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.