<div dir="ltr"><div><div><div><div><div><div><div><div>Hi List,<br></div>I have a 4 Bands (RGB-IR) GeoTIFF for which I also have an external mask.tif which has been created starting from a mask.shp shapefile using this command:<br><br><span style="font-size:13px;font-family:arial,sans,sans-serif"><i>gdal_rasterize
-ot Byte -l mask -CO "TILED=YES" -CO "NBITS=1" -CO
"PHOTOMETRIC=MINISBLACK" -CO "COMPRESS=DEFLATE" -a cat -burn 1 -ts 16384
16384 mask.shp mask.tif</i><br><br></span></div><span style="font-size:13px;font-family:arial,sans,sans-serif">So that my mask.tif is 1 bit B/W GeoTIFF.<br></span></div><span style="font-size:13px;font-family:arial,sans,sans-serif">Now, I would like to add it as Internal Mask of the main GeoTIFF.<br></span></div><span style="font-size:13px;font-family:arial,sans,sans-serif">I have played a bit with GDAL translate and buildvrt and, due to constraints on number of bands, I ended up with this commands:<br><br></span></div><i><span style="font-size:13px;font-family:arial,sans,sans-serif">gdalbuildvrt -b 1 1.vrt origin.tif <br></span><span style="font-size:13px;font-family:arial,sans,sans-serif">gdalbuildvrt -b 2 2.vrt origin.tif<br></span><span style="font-size:13px;font-family:arial,sans,sans-serif">gdalbuildvrt -b 3 3.vrt origin.tif <br></span></i><span style="font-size:13px;font-family:arial,sans,sans-serif"><i>gdalbuildvrt -b 4 4.vrt origin.tif <br></i><br></span></div><span style="font-size:13px;font-family:arial,sans,sans-serif">In order to separate the bands<br></span></div><span style="font-size:13px;font-family:arial,sans,sans-serif">Then:<br><i>gdalbuildvrt -separate out.vrt 1.vrt 2.vrt 3.vrt 4.vrt mask.tif </i><br></span></div><div><span style="font-size:13px;font-family:arial,sans,sans-serif"><br>in order to re-aggregate them into a single raster, together with the mask.<br></span></div><div><span style="font-size:13px;font-family:arial,sans,sans-serif"><br>And finally:<br><br><i>gdal_translate -of GTIFF -CO "PHOTOMETRIC=RGB" -CO "ALPHA=NO" -CO "TILED=YES" -CO "COMPRESS=DEFLATE" -b 1 -b 2 -b 3 -b 4 -mask 5 out.vrt final.tif</i><br><br></span></div><span style="font-size:13px;font-family:arial,sans,sans-serif">So that I copy the 4 bands from VRT and add the 5th band as mask.<br></span><div><span style="font-size:13px;font-family:arial,sans,sans-serif"><br></span></div><div><span style="font-size:13px;font-family:arial,sans,sans-serif">I have 2 issues with that:<br></span></div><div><span style="font-size:13px;font-family:arial,sans,sans-serif">1) This solution is really not optimal. Wondering if there is a single command to attach an external tif as a mask band of an existing raster (provided it has same CRS, resolution, bbox, ecc)<br></span></div><div><span style="font-size:13px;font-family:arial,sans,sans-serif">2) What I get is that the mask has been set as an external file final.tif.msk.<br></span></div><div><span style="font-size:13px;font-family:arial,sans,sans-serif">Is there any config option or opening option to open the final.tif in update mode so that the band mask can be added as internal geotiff mask?<br><br></span></div><div><span style="font-size:13px;font-family:arial,sans,sans-serif">Please, let me know what do you think about it.<br></span></div><div><span style="font-size:13px;font-family:arial,sans,sans-serif">Cheers,<br></span></div><div><span style="font-size:13px;font-family:arial,sans,sans-serif">Daniele<br></span></div><div><div><div><div><div><div><div><br clear="all"><div><div><br>-- <br><div data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><span style="font-size:12.8px">==</span><br></div><div dir="ltr"><span style="font-size:12.8px">GeoServer Professional Services from the experts! Visit</span><br style="font-size:12.8px"><a href="http://goo.gl/it488V" style="color:rgb(17,85,204);font-size:12.8px" target="_blank">http://goo.gl/it488V</a><span style="font-size:12.8px"> for more information.</span><br>
==<br>
<br>Ing. Daniele Romagnoli<br>Senior Software Engineer<br><br>GeoSolutions S.A.S.<br><span style="font-size:12.8px">Via di Montramito 3/A</span><br>55054 Massarosa (LU)<br>Italy<br>phone: <a href="tel:%2B39%200584%20962313" value="+390584962313" target="_blank">+39 0584 962313</a><br>fax: <a href="tel:%2B39%200584%201660272" value="+3905841660272" target="_blank">+39 0584 1660272</a><br><br><a href="http://www.geo-solutions.it" target="_blank">http://www.geo-solutions.it</a><br><a href="http://twitter.com/geosolutions_it" target="_blank">http://twitter.com/geosolutions_it</a><br><br>-------------------------------------------------------<br><p><span lang="IT"><font size="1"><b>AVVERTENZE AI SENSI DEL D.Lgs. 196/2003</b></font></span></p><p><span lang="IT"><font size="1">Le
informazioni contenute in questo messaggio di posta elettronica e/o
nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il
loro utilizzo è consentito esclusivamente al destinatario del messaggio,
per le finalità indicate nel messaggio stesso. Qualora riceviate questo
messaggio senza esserne il destinatario, Vi preghiamo cortesemente di
darcene notizia via e-mail e di procedere alla distruzione del messaggio
stesso, cancellandolo dal Vostro sistema. Conservare il messaggio
stesso, divulgarlo anche in parte, distribuirlo ad altri soggetti,
copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento
contrario ai principi dettati dal D.Lgs. 196/2003.</font></span></p><p><span lang="IT"><font size="1"> </font></span></p><p><font size="1">The
information in this message and/or attachments, is intended solely for
the attention and use of the named addressee(s) and may be confidential
or proprietary in nature or covered by the provisions of privacy act
(Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection
Code).Any use not in accord with its purpose, any disclosure,
reproduction, copying, distribution, or either dissemination, either
whole or partial, is strictly forbidden except previous formal approval
of the named addressee(s). If you are not the intended recipient, please
contact immediately the sender by telephone, fax or e-mail and delete
the information in this message that has been received in error. The
sender does not give any warranty or accept liability as the content,
accuracy or completeness of sent messages and accepts no responsibility
for changes made after they were sent or for other risks which arise as
a result of e-mail transmission, viruses, etc.</font></p><br></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></div>