[gdal-dev] Translating files with a external mask file
Even Rouault
even.rouault at mines-paris.org
Thu Oct 27 14:43:51 EDT 2011
Le jeudi 27 octobre 2011 18:48:07, Frank Warmerdam a écrit :
> On Thu, Oct 27, 2011 at 8:14 AM, Travis Kirstine
>
> <traviskirstine at gmail.com> wrote:
> > I have a rgb geotiff with a external mask file
> > rgb_withmaskfile.tif.msk, I would like to convert the files to a
> > compressed GeoTiff using a command simalar to the one below. This
> > command will generate a illegal band # error
> >
> > gdal_translate rgb_withmaskfile.tif results.tif -b 1 -b 2 -b 3 -mask 4
> > -co COMPRESS=JPEG -co PHOTOMETRIC=YCBCR --config
> > GDAL_TIFF_INTERNAL_MASK YES
>
> Travis,
>
> Is the mask really band 4? I presume the mask (from the .msk file)
> is not treated as a regular band of the source file and cannot be
> referenced as such. I would hope that gdal_translate would
> automatically try to translate the associated mask though I must
> confess I haven't tried this myself. If it does not then please file a
> ticket.
2 possibilities I have verified to work with GDAL >= 1.8.0 :
1) As suggested by Frank, the easiest where you don't have to play with the -b
and -mask arguments :
gdal_translate rgb_withmaskfile.tif results.tif -co COMPRESS=JPEG -co
PHOTOMETRIC=YCBCR --config GDAL_TIFF_INTERNAL_MASK YES
2) Another one more verbose :
gdal_translate rgb_withmaskfile.tif results.tif -b 1 -b 2 -b 3 -mask mask -co
COMPRESS=JPEG -co PHOTOMETRIC=YCBCR --config GDAL_TIFF_INTERNAL_MASK YES
--> The difference with yours is that the band number for the -mask argument is
the mask keyword. "-mask mask" means that you use as a mask the mask band of
the source dataset.
>
> Best regards,
More information about the gdal-dev
mailing list