[gdal-dev] Problem with image overview creation in GTiff files
Even Rouault
even.rouault at mines-paris.org
Mon Oct 20 14:56:39 EDT 2008
Vincent,
Thanks for your hints. I've tried the following python script :
import gdal
ds=gdal.GetDriverByName('GTiff').Create('tiled.tif',10000,10000,4)
ds.GetRasterBand(1).Fill(0)
ds.BuildOverviews('NEAR', overviewlist = [2])
(I think it is important that the size of the image must be big enough in
comparison to the block cache so that actual data goes to the disk before the
overview building. The fact that it is tiled and compressed doesn't change
the behaviour)
On trunk, the scripts fails with the error messages reported in the previous
emails. I also confirms that closing and reopening in update mode works
around the error.
On branches/1.5 it succeeds.
Then I imported frmt/gtiff/libtiff/* from a trunk tree into an 1.5 tree,
compiled and the test fails
And the opposite, I imported frmt/gtiff/libtiff/* from a 1.5 tree into a
trunk tree, compiled and the test succeeds
So it is clearly a refresh from upstream libtiff in trunk since 1.5 that broke
that test.
Ticket http://trac.osgeo.org/gdal/ticket/2621 created
Even
Le Monday 20 October 2008 09:52:03 Vincent Schut, vous avez écrit :
> Frank Warmerdam wrote:
> > Ozy Sjahputera wrote:
> >> I am trying to create image overviews for a GTiff file using
> >> GDALDataset::BuildOverviews. I keep getting various errors such as:
> >>
> >> ERROR 1: TIFFSetField:VISUAL.tif: Cannot modify tag "Compression"
> >> while writing
> >
> > ...
> >
> >> writing
> >> ERROR 1: TIFFSetField:VISUAL.tif: Cannot modify tag "TileLength" while
> >> writing
> >> ERROR 1: TIFFBuildOverviews:Can not write tiles to a stripped image
> >>
> >>
> >> Here is my code:
> >>
> >> int OverviewList[5] = { 2, 4, 8, 16, 32 };
> >> CPLErr overview_err = outDS->BuildOverviews( "AVERAGE_MAGPHASE", 5,
> >> OverviewList, 0, NULL, NULL, NULL );
> >>
> >>
> >> I have used BuildOverviews before on HFA images and they are fine. Any
> >> idea?
> >
> > Ozy,
> >
> > I'm surprised. I wonder if you might have opened your file in read-only
> > mode? Can you reproduce the problem with the gdaladdo commandline
> > program?
> >
> > Best regards,
>
> Frank,
>
> I'm encountering this issue pretty frequently. It happens when I create
> a tiled, compressed tiff (I'm using python but apparently that doesn't
> make a difference), write tile data into it, and then call the
> buildOverviews method. I thought I'd reported this issue (at least to
> this list), but it might have slipped my mind. Because I've found and by
> default implemented a fairly simple workaround, I totally forgot about
> it till now. The workaround is simple: first close and reopen the
> dataset, then buildOverviews. Haven't tried if flushing instead of
> reopening is enough.
> Should I file a ticket on this?
>
> Vincent.
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
More information about the gdal-dev
mailing list