[Gdal-dev] Python Woes
Christopher Condit
condit at sdsc.edu
Thu May 18 15:20:15 EDT 2006
Hi All-
I know little to nothing about Python, but am using it to perform some
simple math on a collection of raster images. In this case, calculating
mean and variance cellwise on a collection of 40 raster files...
Here's what my code looks like as I collect all of the input bands into
an array:
magnitudeBands = []
thetaBands = []
for depth in range(40):
inFile = "C:\\develop\\data\\l%i\\vel-%i.tif" % (depth, month)
inDataset = gdal.Open( inFile, GA_ReadOnly )
magnitudeBands.append(inDataset.GetRasterBand(1))
thetaBands.append(inDataset.GetRasterBand(2))
... At this point when I examine magnitudeBands, everything looks
correct.
for y in range(magnitudeBands[0].YSize):
for band in range(len(magnitudeBands)):
line = magnitudeBands[band].ReadAsArray( 0, y,
magnitudeBands[band].XSize, 1, magnitudeBands[band].XSize, 1 )
But at this point, I get an exception:
TypeError: Access window out of range in RasterIO(). Requested
(0,0) of size 720x1 on raster of 9479520x0.
Am I missing something fundamental about Python or about the GDAL python
module? Thanks for any help...
-Chris
More information about the Gdal-dev
mailing list