<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Jun 1, 2018 at 7:14 PM, Even Rouault <span dir="ltr"><<a href="mailto:even.rouault@spatialys.com" target="_blank">even.rouault@spatialys.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On vendredi 1 juin 2018 18:25:27 CEST Sean Gillies wrote:<br>
> Hi Even,<br>
> <br>
> I got waylaid in following up, but am finally doing so now. Yes, I can also<br>
> confirm that the .msk file is being read over the internet. I'm grateful<br>
> for the CURL logging in GDAL, it's very handy.<br>
> <br>
> However, I'm perplexed by not being able to get the mask I expect from the<br>
> warped VRT I'm creating using GDALAutoCreateWarpedVRT. The source file has<br>
> a mask, but no mask materializes in the warped VRT. I have a WarpedVRT<br>
> class in Rasterio that calls GDALAutoCreateWarpedVRT and is equivalent to<br>
> the Python GDAL code you showed. It has a method that calls<br>
> GDALGetMaskFlags and here's what that reports.<br>
> <br>
> with rasterio.open('<a href="https://oin-hotosm.s3.amazonaws.com/" rel="noreferrer" target="_blank">https://oin-<wbr>hotosm.s3.amazonaws.com/</a><br>
> 5a324a622553e6000ce5aaf5/0/<wbr>3fa181a1-425c-4e53-b49f-<wbr>ea72884da097.tif') as<br>
> src, WarpedVRT(src, dst_crs=src.crs) as vrt:<br>
>     print(vrt.mask_flag_enums)<br>
> <br>
> # Output:<br>
> # ([<MaskFlags.all_valid: 1>], [<MaskFlags.all_valid: 1>],<br>
> [<MaskFlags.all_valid: 1>])<br>
> <br>
> The source has a per-dataset mask, but this doesn't surface in the VRT. It<br>
> reports that all the pixels are valid.<br>
<br>
</span>Hi Sean,<br>
<br>
OK I now understand what you meant. The warper in general in GDAL (so not <br>
specific to the VRT warping) can use the mask of the input dataset, but <br>
doesn't generate one in output. However it should be able to generate an alpha <br>
band if you call GDALCreateWarpedVRT() with psOptions->nDstAlphaBand = 4 <br>
(couldn't test easily, but hopefully should work)<br>
<div class="HOEnZb"><div class="h5"><br>
Even<br></div></div></blockquote><div><br></div><div>After setting that warp option and setting the color interpretation of the resulting band to GCI_AlphaBand, I'm in business!</div><div><br></div><div>Thanks, Even!</div></div><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Sean Gillies</div></div>
</div></div>