[Qgis-user] Adding alpha band to raster

Alister Hood alister.hood at gmail.com
Mon Jan 24 13:37:23 PST 2022


Personally I would create a .vrt using gdal_translate, with these
"additional command line parameters":

 -b 1 -b 2 -b 3 -b 1 -colorinterp_4 alpha -scale_4 0 255 255 255

This assumes 8 bit RGB input, but you can adapt it for something else.
It does work even before georeferencing.
But depending on your workflow it might be easier just to convert to RGBA
with something like imagemagick, or to open in MS Paint and save as
PNG, which silently adds an alpha channel.

Regards,
Alister

> Date: Mon, 24 Jan 2022 10:33:56 -0400
> From: Kirk Schmidt <kirk at nortekresources.com>
> To: qgis-user at lists.osgeo.org
> Subject: Re: [Qgis-user] Adding alpha band to raster
> Message-ID: <46938c47-4f37-44ac-5f96-468f29258783 at nortekresources.com>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> Hi Nicolas:
>
> I just had an idea, why not use gdal directly??? I know gdalwarp has a
> -dstalpha switch to code null data Assuming this is what you want the
> alpha band for)
>
> Kirk
>
>
> On 1/21/2022 6:06 PM, Nicolas Cadieux wrote:
> > Hi,
> >
> > I don't see it in the current processing algorithms. I see lot's or
> > r.out... but not that one:(? I guess I could do it in Grass...
> >
> > Thanks for the idea!
> >
> > Nicolas
> >
> > On 2022-01-21 1:37 p.m., Kirk Schmidt wrote:
> >> Hi Nicholas:
> >>
> >> Try r.out.gdal
> >>
> >> https://grass.osgeo.org/grass78/manuals/r.out.gdal.html
> >>
> >> Kirk Schmidt
> >>
> >>
> >> On 1/21/2022 2:25 PM, Nicolas Cadieux wrote:
> >>> Hi,
> >>>
> >>> What is the easiest way, in QGIS3, to add an alpha band to a
> >>> raster?? Alpha bands are handy with the georeferencer. Currently, I
> >>> am just adding it in GIMP before I start the georeferencer.
> >>>
> >>> Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20220125/046e5723/attachment.html>


More information about the Qgis-user mailing list