[prev in list] [next in list] [prev in thread] [next in thread] 

List:       qgis-user
Subject:    Re: [Qgis-user] Adding alpha band to raster
From:       Alister Hood <alister.hood () gmail ! com>
Date:       2022-01-24 21:37:23
Message-ID: CAF6hL+UFuB_+m8+N1vHH0BHP7eHhaz39Mw+Eebn0UX4VzOKhFw () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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@nortekresources.com>
> To: qgis-user@lists.osgeo.org
> Subject: Re: [Qgis-user] Adding alpha band to raster
> Message-ID: <46938c47-4f37-44ac-5f96-468f29258783@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

[Attachment #5 (text/html)]

<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div \
dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div \
dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div \
dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div \
dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div \
dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div \
dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div \
dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div \
dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Personally I \
would create a .vrt using gdal_translate, with these &quot;additional command line \
parameters&quot;:<br><br></div><div dir="ltr">  -b 1 -b 2 -b 3 -b 1 -colorinterp_4 \
alpha -scale_4 0 255 255 255<br><br></div><div dir="ltr">This assumes 8 bit RGB \
input, but you can adapt it for something else.</div><div dir="ltr">It does work even \
before georeferencing.</div><div dir="ltr">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.</div><div \
dir="ltr"><br></div><div dir="ltr">Regards,</div><div dir="ltr">Alister<br><br>&gt; \
Date: Mon, 24 Jan 2022 10:33:56 -0400<br>&gt;  From: Kirk Schmidt &lt;<a \
href="mailto:kirk@nortekresources.com">kirk@nortekresources.com</a>&gt;<br>&gt;  To: \
<a href="mailto:qgis-user@lists.osgeo.org">qgis-user@lists.osgeo.org</a><br>&gt;  \
Subject: Re: [Qgis-user] Adding alpha band to raster<br>&gt;  Message-ID: &lt;<a \
href="mailto:46938c47-4f37-44ac-5f96-468f29258783@nortekresources.com">46938c47-4f37-44ac-5f96-468f29258783@nortekresources.com</a>&gt;<br>&gt; \
Content-Type: text/plain; charset=UTF-8; format=flowed<br>&gt;  <br>&gt;  Hi \
Nicolas:<br>&gt;  <br>&gt;  I just had an idea, why not use gdal directly??? I know \
gdalwarp has a<br>&gt;  -dstalpha switch to code null data Assuming this is what you \
want the<br>&gt;  alpha band for)<br>&gt;  <br>&gt;  Kirk<br>&gt;  <br>&gt;  <br>&gt; \
On 1/21/2022 6:06 PM, Nicolas Cadieux wrote:<br>&gt;  &gt; Hi,<br>&gt;  &gt;<br>&gt;  \
&gt; I don&#39;t see it in the current processing algorithms. I see lot&#39;s \
or<br>&gt;  &gt; r.out... but not that one:(? I guess I could do it in \
Grass...<br>&gt;  &gt;<br>&gt;  &gt; Thanks for the idea!<br>&gt;  &gt;<br>&gt;  &gt; \
Nicolas<br>&gt;  &gt;<br>&gt;  &gt; On 2022-01-21 1:37 p.m., Kirk Schmidt \
wrote:<br>&gt;  &gt;&gt; Hi Nicholas:<br>&gt;  &gt;&gt;<br>&gt;  &gt;&gt; Try \
r.out.gdal<br>&gt;  &gt;&gt;<br>&gt;  &gt;&gt; <a \
href="https://grass.osgeo.org/grass78/manuals/r.out.gdal.html">https://grass.osgeo.org/grass78/manuals/r.out.gdal.html</a><br>&gt; \
&gt;&gt;<br>&gt;  &gt;&gt; Kirk Schmidt<br>&gt;  &gt;&gt;<br>&gt;  &gt;&gt;<br>&gt;  \
&gt;&gt; On 1/21/2022 2:25 PM, Nicolas Cadieux wrote:<br>&gt;  &gt;&gt;&gt; \
Hi,<br>&gt;  &gt;&gt;&gt;<br>&gt;  &gt;&gt;&gt; What is the easiest way, in QGIS3, to \
add an alpha band to a<br>&gt;  &gt;&gt;&gt; raster?? Alpha bands are handy with the \
georeferencer. Currently, I<br>&gt;  &gt;&gt;&gt; am just adding it in GIMP before I \
start the georeferencer.<br>&gt;  &gt;&gt;&gt;<br>&gt;  &gt;&gt;&gt; \
Thanks</div></div></div></div></div></div></div></div></div></div></div></div></div></ \
div></div></div></div></div></div></div></div></div></div></div></div></div></div></di \
v></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>




_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic