[gdal-dev] How to add an external mask as internal mask to a GeoTIFF?

Even Rouault even.rouault at spatialys.com
Tue Jul 19 06:12:24 PDT 2016


Hi Daniele,

> 
> I have 2 issues with that:
> 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)

None that I can think of. Your workflow is probably close to optimum if you 
don't want to create the VRT at hand

I think we would welcome a contribution of a Python script that would allow 
things like :
- gdal_add_band.py -mask in.tif mask.tif out.vrt
- gdal_add_band.py -alpha in.tif alpha.tif out.vrt
- gdal_add_band.py in.tif extra_band.tif out.vrt

> 2) What I get is that the mask has been set as an external file
> final.tif.msk.
> 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?

Yes, "--config GDAL_TIFF_INTERNAL_MASK YES". See "Internal nodata masks" 
paragraph of http://gdal.org/frmt_gtiff.html

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list