[gdal-dev] BandWriteArray and FlushCache question
Gong, Shawn (Contractor)
Shawn.Gong at drdc-rddc.gc.ca
Mon Jan 19 16:44:33 EST 2009
adding "self.balanced_ds = None" seems to do the trick.
From: gdal-dev-bounces at lists.osgeo.org
[mailto:gdal-dev-bounces at lists.osgeo.org] On Behalf Of Frank Warmerdam
Sent: Monday, January 19, 2009 4:03 PM
To: Gong, Shawn (Contractor)
Cc: gdal-dev at lists.osgeo.org
Subject: Re: [gdal-dev] BandWriteArray and FlushCache question
Gong, Shawn (Contractor) wrote:
> hi list,
> I recently upgraded to gdal 1.6.0 and found that one Python function
> that used to work in 1.4.4 no longer works.
> The purpose of function was to read in a band, perform matrix
> manipulation (in this case, subtract a baseline) and resave.
> The error that I am getting is that in the new dataset the last
> of lines DN are written zero. If I take out the last line
> "self.balanced_ds.FlushCache()" then the entire dataset is written as
> zeros. None of errors would happen in gdal 1.4.4.
> Is there any changes in gdal 1.6.0 w.r.t. FlushCache() ? What is the
> right way to perform this?
> for block in range( nblocks ):
> first_line = RCS_PROC_STEP*block
> if block == nblocks - 1:
> nlines = ysize - first_line
> datablock = gdalnumeric.BandReadAsArray( bandobj, 0, first_line,
> xsize, nlines )
> datablock = datablock - baseline
> gdalnumeric.BandWriteArray( bandobj,
> datablock.astype(gdalnumeric.Int16), 0, first_line )
I'm not sure of any reason the script shouldn't work properly. But I
will note that aspects of the TIFF file are only written out when the
file is closed. You may find it helpful to do "self.balanced_ds = None"
at the end so that python will release the dataset and it can be closed.
I'm not sure of what environment you are running your script in.
at script end this would happen anyways.
I set the clouds in motion - turn up | Frank Warmerdam,
warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | Geospatial Programmer for Rent
gdal-dev mailing list
gdal-dev at lists.osgeo.org
More information about the gdal-dev