<div dir="ltr">Thanks Even! I'll give it a try.<div><br></div><div>Could you please help me understand the difference between two next cases. When I do either</div><div><br></div><div>    gdal_translate rgbmask.vrt rgb_with_external_msk.vrt -mask none -b 1 -b 2 -b 3 -of VRT</div>    or<div>    gdal_translate rgbmask.vrt rgb_with_external_msk.vrt -mask none -of VRT<div><br></div><div>I'm getting the same (I would say expected) result: VRT raster with 3 VRTRasterBand / 1  SimpleSource element per each band.</div><div><br></div><div>But if I do:</div><div><br></div><div>    gdal_translate rgbmask.vrt rgb_with_external_msk.vrt -mask none -b 1 -b 2 -b 3 -of VRT</div><div><br></div><div>I'm getting VRT with:</div><div><br></div><div>1) 3 VRTRasterBand + 1 MaskBand</div><div>2) Each VRTRasterBand has many SimpleSource elements with various DstRect.</div><div><br></div><div>So it seems if we don't tell to GDAL not to use mask it copies it by default. But why the structure of VRTRasterBand is different?</div><div><br></div><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 22, 2020 at 12:09 PM Even Rouault <<a href="mailto:even.rouault@spatialys.com">even.rouault@spatialys.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>
<div style="font-family:monospace;font-size:9pt;font-weight:400;font-style:normal">
<p style="margin:0px;text-indent:0px">On mardi 21 avril 2020 23:54:03 CEST Denis Rykov wrote:</p>
<p style="margin:0px;text-indent:0px">> Hello,</p>
<p style="margin:0px;text-indent:0px">> </p>
<p style="margin:0px;text-indent:0px">> I'm using *.vrt file that is built atop of COG rasters with internal mask</p>
<p style="margin:0px;text-indent:0px">> (PER_DATASET) + external overview file *.vrt.ovr.</p>
<p style="margin:0px;text-indent:0px">> These files are stored on Azure Blob Storage and I get access to them using</p>
<p style="margin:0px;text-indent:0px">> /vsiaz scheme.</p>
<p style="margin:0px;text-indent:0px">> I've found out that when I read data from this VRT GDAL does few requests</p>
<p style="margin:0px;text-indent:0px">> to *.vrt.ovr to get data and lots of requests to TIFFs to extract a mask.</p>
<p style="margin:0px;text-indent:0px">> </p>
<p style="margin:0px;text-indent:0px">> What are the ways to overcome this? I hope I can put mask into</p>
<p style="margin:0px;text-indent:0px">> sidecar *.vrt.msk file. Is that correct?</p>
<p style="margin:0px;text-indent:0px">> Is there a way to store a mask inside a *.vrt.ovr file?</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">Hum, given a rgbmask.vrt that has a mask band, the following probably works</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">gdal_translate rgbmask.vrt rgb_with_external_msk.vrt -b 1 -b 2 -b 3 -of VRT</p>
<p style="margin:0px;text-indent:0px">gdal_translate rgbmask.vrt rgb_with_external_msk.vrt.msk -b mask -of VRT -mo INTERNAL_MASK_FLAGS_1=2 -mo INTERNAL_MASK_FLAGS_2=2 -mo INTERNAL_MASK_FLAGS_3=2</p>
<p style="margin:0px;text-indent:0px">gdaladdo rgb_with_external_msk.vrt.msk</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">You could probably avoid rgb_with_external_msk.vrt referencing rgbmask.vrt, by making it directly refer to your COG sources.</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">Even</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">-- </p>
<p style="margin:0px;text-indent:0px">Spatialys - Geospatial professional services</p>
<p style="margin:0px;text-indent:0px"><a href="http://www.spatialys.com" target="_blank">http://www.spatialys.com</a></p></div></blockquote></div>