[gdal-dev] How to add an external mask as internal mask to a GeoTIFF?
even.rouault at spatialys.com
Tue Jul 19 06:34:14 PDT 2016
Le mardi 19 juillet 2016 15:27:05, Daniele Romagnoli a écrit :
> Hi Even,
> thanks for the feedback.
> I was using it as a -co "GDAL_TIFF_INTERNAL_MASK=YES" to the latest command
> and I was getting
> *Warning 6: driver GTiff does not support creation option
> Appending the line you provided me to that command worked!
Yes, there is some confusion around configuration options vs creation options,
and you must be careful about the terminology used in the documentation.
"Configuration options" are specified either with "--config name value" or as
environmenet variables or with CPLSetConfigOption(name,value) in C
"Creation options" are specified with gdal_translate -co name=value or as
"name=value" strings in the papszOptions argument of Create()/CreateCopy()
methods in C/C++
GDAL_TIFF_INTERNAL_MASK is a configuration option since it can be used on an
existing TIFF opened in update mode, to which you add a mask. Thus a creation
option couldn't be used in that case (since a creation option is for when the
target file does not exist yet).
> On Tue, Jul 19, 2016 at 3:12 PM, Even Rouault <even.rouault at spatialys.com>
> > 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
Spatialys - Geospatial professional services
More information about the gdal-dev