[gdal-dev] gdal_translate: extracting mask band and its overviews

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[gdal-dev] gdal_translate: extracting mask band and its overviews

Emanuele Tajariol-2
Hi,

I'm trying and extract the single mask band out of a geotiff file using
gdal_translate.
The tiff file also contains overviews of mask band, and I'd like to extract them
as well (In the end of the mail there's a fragment of the input file's
gdalinfo.)

The command I'm using is:

gdal_translate -b mask \
   --config GDAL_TIFF_INTERNAL_MASK YES \
   -co COPY_SRC_OVERVIEWS=yes \
   -co TILED=yes  \
   -co COMPRESS=DEFLATE   \
   intput_file.tif output_mask.tif

Anyway the output file does not contain any overview at all.

I get the very same result also removing the GDAL_TIFF_INTERNAL_MASK config
(which should not be needed anyway since the mask band is exported as a data
band).

Am I missing any command line option or is it possibile at all?


   Thanks,
   Emanuele


====
Input file gdalinfo fragment:

[...]
Size is 19584, 19584
[...crs, origin, pixel size...]
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  COMPRESSION=YCbCr JPEG
  INTERLEAVE=PIXEL
  SOURCE_COLOR_SPACE=YCbCr
[...Corner coords...]
Band 1 Block=256x256 Type=Byte, ColorInterp=Red
  Overviews: 9792x9792, 4896x4896, 2448x2448, 1224x1224, 612x612, 306x306
  Mask Flags: PER_DATASET
  Overviews of mask band: 9792x9792, 4896x4896, 2448x2448, 1224x1224, 612x612,
306x306
  Metadata:
    COLORINTERP=Red
Band 2 Block=256x256 Type=Byte, ColorInterp=Green
  Overviews: 9792x9792, 4896x4896, 2448x2448, 1224x1224, 612x612, 306x306
  Mask Flags: PER_DATASET
  Overviews of mask band: 9792x9792, 4896x4896, 2448x2448, 1224x1224, 612x612,
306x306
  Metadata:
    COLORINTERP=Green
Band 3 Block=256x256 Type=Byte, ColorInterp=Blue
  Overviews: 9792x9792, 4896x4896, 2448x2448, 1224x1224, 612x612, 306x306
  Mask Flags: PER_DATASET
  Overviews of mask band: 9792x9792, 4896x4896, 2448x2448, 1224x1224, 612x612,
306x306
  Metadata:
    COLORINTERP=Blue
[end]

====
Output file gdalinfo fragment:

[...]
Size is 19584, 19584
[...crs, origin, pixel size...]
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  COMPRESSION=DEFLATE
  INTERLEAVE=BAND
[...Corner coords...]
Band 1 Block=256x256 Type=Byte, ColorInterp=Gray
[end]

--

Regards,
Emanuele Tajariol
==
GeoServer Professional Services from the experts! Visit http://goo.gl/it488V 
for more information.
==

Ing. Emanuele Tajariol
Technical Lead

GeoSolutions S.A.S.
Via di Montramito 3/A
55054  Massarosa (LU)
Italy
phone: +39 0584 962313
fax:      +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------
AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i
file/s allegato/i sono da considerarsi strettamente riservate. Il loro utilizzo
è consentito esclusivamente al destinatario del messaggio, per le finalità
indicate nel messaggio stesso. Qualora riceviate questo messaggio senza
esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e-
mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal
Vostro sistema. Conservare il messaggio stesso, divulgarlo anche in parte,
distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse,
costituisce comportamento contrario ai principi dettati dal D.Lgs. 196/2003.
 
The information in this message and/or attachments, is intended solely for the
attention and use of the named addressee(s) and may be confidential or
proprietary in nature or covered by the provisions of privacy act (Legislative
Decree June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not
in accord with its purpose, any disclosure, reproduction, copying,
distribution, or either dissemination, either whole or partial, is strictly
forbidden except previous formal approval of the named addressee(s). If you
are not the intended recipient, please contact immediately the sender by
telephone, fax or e-mail and delete the information in this message that has
been received in error. The sender does not give any warranty or accept
liability as the content, accuracy or completeness of sent messages and
accepts no responsibility  for changes made after they were sent or for other
risks which arise as a result of e-mail transmission, viruses, etc.
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: gdal_translate: extracting mask band and its overviews

Even Rouault-2

On jeudi 31 août 2017 18:55:54 CEST Emanuele Tajariol wrote:

> Hi,

>

> I'm trying and extract the single mask band out of a geotiff file using

> gdal_translate.

> The tiff file also contains overviews of mask band, and I'd like to extract

> them as well (In the end of the mail there's a fragment of the input file's

> gdalinfo.)

>

> The command I'm using is:

>

> gdal_translate -b mask \

> --config GDAL_TIFF_INTERNAL_MASK YES \

> -co COPY_SRC_OVERVIEWS=yes \

> -co TILED=yes \

> -co COMPRESS=DEFLATE \

> intput_file.tif output_mask.tif

>

> Anyway the output file does not contain any overview at all.

 

Emanuele,

 

COPY_SRC_OVERVIEWS=YES will only work if you do a "bare" gdal_translate, ie if you use only source, target, output format and potentially creation options. Here the -b mask causes an intermediate VRT to be created, which no longer exposes the source overviews to the output GTiff driver (although this VRT dataset can still use the overviews of the source when doing downsampling operations. See below)

 

However, assuming overview dimensions following a power of 2 suite, you could do:

 

gdal_translate in.tif temp.tif -b mask

gdal_translate in.tif temp.tif.ovr -b mask -outsize 50% 50% (should extract the overview of the mask without actually resampling from full resolution)

gdal_translate in.tif temp.tif.ovr.ovr -b mask -outsize 25% 25%

gdal_translate temp.tif out.tif -co COPY_SRC_OVERVIEWS=yes

 

or even:

 

gdal_translate in.tif temp.vrt -b mask -of VRT

gdal_translate in.tif temp.vrt.ovr -b mask -outsize 50% 50% -of VRT

gdal_translate in.tif temp.vrt.ovr.ovr -b mask -outsize 25% 25% -of VRT

gdal_translate temp.vrt out.tif -co COPY_SRC_OVERVIEWS=yes

 

 

If you build GDAL from source, there's also the "dumpoverviews" utility that is built and that dumps overviews, mask bands and mask band overviews in separate TIFF file.

 

Even

 

--

Spatialys - Geospatial professional services

http://www.spatialys.com


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev