<div dir="ltr">Made it after some effort.<div>Here is the final query, exporting to a .hex file:</div><div><br></div><div><div style="font-size:12.8px">COPY (</div><div style="font-size:12.8px"><span style="white-space:pre-wrap"> </span>select encode(ST_AsPNG(r, ARRAY[1,2,3]), 'hex')</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">       </span>FROM (</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><span style="white-space:pre-wrap">            </span>WITH original AS (</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">                    </span>SELECT 1 AS rid, ST_AddBand(ST_AddBand(ST_<wbr>AddBand(ST_MakeEmptyRaster(<wbr>100,100,0,0,1), 1, '8BUI', 16, 999), 2, '8BUI', 46, 999), 3, '8BUI', 184, 999) AS rast</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">             </span>), --0,0,255</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">          </span>empty AS (</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">                    </span>SELECT 1 AS rid, ST_AddBand(ST_AddBand(ST_<wbr>AddBand(ST_MakeEmptyRaster(<wbr>256,256,0,0,1), 1, '8BUI', 0, 999), 2, '8BUI', 0, 999), 3, '8BUI', 0, 999) AS rast</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">         </span>)--255,255,0</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><span style="white-space:pre-wrap">              </span>select </div><div style="font-size:12.8px"><span style="white-space:pre-wrap">              </span>ST_AddBand(</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">                   </span>ST_MapAlgebra(original.rast,1,<wbr>empty.rast,1,'([rast1.val] + [rast2.val])','8BUI','UNION'),</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">                  </span>ARRAY[ST_MapAlgebra(original.<wbr>rast,2,empty.rast,2,'([rast1.<wbr>val] + [rast2.val])','8BUI','UNION'), ST_MapAlgebra(original.rast, 3,empty.rast,3,'([rast1.val] + [rast2.val])','8BUI','UNION')]</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">              </span>)</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">             </span>as r</div><div style="font-size:12.8px"><span style="white-space:pre-wrap">          </span>FROM original,empty</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><span style="white-space:pre-wrap">       </span>) AS t</div><div style="font-size:12.8px">) TO '/tmp/test.hex';</div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">after that, I just run:</div><div style=""><span style="font-size:12.8px">xxd -p -r test.hex > test.png</span><br></div><div style=""><span style="font-size:12.8px"><br></span></div><div style=""><span style="font-size:12.8px">And voilĂ .</span></div><div style=""><span style="font-size:12.8px"><br></span></div><div style=""><span style="font-size:12.8px">--Rumanovsk</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 15, 2016 at 1:15 PM, Pierre Racine <span dir="ltr"><<a href="mailto:Pierre.Racine@sbf.ulaval.ca" target="_blank">Pierre.Racine@sbf.ulaval.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">ST_Union works on overlapping rasters as well but maybe you have to provide two 3 bands rasters. If your rasters are tiled, you also have to GROUP BY tiles having the same alignment:<br>
<br>
GROUP BY ST_UpperleftX(rast), ST_UpperleftY(rast)<br>
<br>
ST_MapAlgebra() should work also. The expression should be equal to the raster with values and the extenttype to the 256x256 pixel one. They shoulp overlap.<br>
<br>
Pierre<br>
<div><div class="h5"><br>
<br>
> -----Original Message-----<br>
> From: postgis-users [mailto:<a href="mailto:postgis-users-bounces@lists.osgeo.org">postgis-users-bounces@<wbr>lists.osgeo.org</a>] On Behalf<br>
> Of Alexander Rumanovsk<br>
> Sent: Wednesday, August 10, 2016 12:40 PM<br>
> To: <a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
> Subject: [postgis-users] Merge rasters with multiple bands<br>
><br>
> Hello all,<br>
><br>
> I'm trying to merge a raster with 3 bands to an empty raster. The empty raster is<br>
> created with the query bellow:<br>
><br>
> ST_AddBand(ST_MakeEmptyRaster(<wbr>256,256,0,0,1), '8BUI'::text,200)<br>
><br>
><br>
> This empty raster is larger than the filled one (which is 100x100). I just need to<br>
> create a raster of 256x256 with the original raster (100x100) information and<br>
> the rest filled with empty information.<br>
> My first idea was to use ST_Union, but found out it just merges tiles, instead of<br>
> rasters.<br>
> Anyone have an idea how can I do that?<br>
><br>
> thanks in advance<br>
> Rumanovsk<br>
</div></div>______________________________<wbr>_________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">http://lists.osgeo.org/<wbr>mailman/listinfo/postgis-users</a></blockquote></div><br></div>