[gdal-dev] gdal cache in python readarray/writearray
Jared Rubin
JARED.RUBIN at saic.com
Sun Jan 6 17:23:06 EST 2008
Support,
With the following python code, I don't understand how when I update an
image file on disk and then open up the dataset again (same file name), that
I don't get the update. As below. However if I just use the original dataset
and call ReadAsArray then I do see the update. I would think that the
FlushCache does as expected...but it seems that calling gdal.Open does not
get the dirty (updated) data.
thanks
Jared
#!/usr/bin/env python
import sys,os,string,shutil
import gdal
from gdalconst import *
dataset = gdal.Open( sys.argv[1], GA_Update )
outputChip = dataset.GetRasterBand(1).ReadAsArray( 0, 0, 10, 10, 10, 10)
print outputChip
print
outputChip[5] = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]
print outputChip
print
dataset.GetRasterBand(1).WriteArray(outputChip)
dataset.GetRasterBand(1).FlushCache()
dataset2 = gdal.Open(sys.argv[1], GA_ReadOnly )
outputChip2 = dataset2.GetRasterBand(1).ReadAsArray( 0, 0, 10, 10, 10, 10)
print outputChip2
print
# below works
outputChip3 = dataset.GetRasterBand(1).ReadAsArray
print outputChip
More information about the gdal-dev
mailing list