1

I was hoping that the following command would give me an alpha-channel PNG which was transparent where the DEM has "nodata":

gdaldem color-relief -alpha -of png dem.tif palette.dat out.png

I get an RGBA PNG alright, but the alpha channel is completely opaque! Why?

I am reasonably convinced that there are "nodata" pixels in dem.tif, because if I add an nv entry to the palette (with some garish colour), I get a lot of this colour in my output, and right where I expect it to be.

gdaldem --version says GDAL 2.2.1, released 2017/06/23.

1
  • Also tried 'GDAL 2.3.2, released 2018/09/21' with the same result. Commented Oct 29, 2018 at 10:57

1 Answer 1

1

Answering my own question: Make sure the nv entry in the palette has four channels (R, G, B, A) with a zero for the alpha value, and it works!

I had mistakenly assumed that the alpha channel would be deduced from the "nodata-ness" of the pixels, but apparently, you have to provide the alpha data explicitly in the palette.

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.